微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

本地主机 Nginx 和 WordPress 配置

如何解决本地主机 Nginx 和 WordPress 配置

我已经为 wordpressNginxMysqL 的本地托管编写了一个 docker-compose 设置。 一切都运行良好,但由于某种原因,我无法从我在 nging.config 文件中提供的 server_name 访问项目,只能从 IP 地址(即:https://foo.local) 我还需要更改 wordpress 文件中的任何内容吗?

Nginx.config:

server {
listen 80;
listen [::]:80;
server_name foo.local www.foo.local;

location ~ /.well-kNown/acme-challenge {
    allow all;
    root /var/www/html;
}

location / {
    rewrite ^ https://$host$request_uri? permanent;
  }
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name foo.local www.foo.local;

client_max_body_size 128M;
index index.PHP index.html index.htm;
root /var/www/html;

ssl_certificate /etc/letsencrypt/live/foo.local/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/foo.local/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;

# modern configuration
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;

add_header x-frame-options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
add_header Strict-Transport-Security "max-age=63072000" always;

# OCSP stapling
ssl_stapling off;
ssl_stapling_verify off;

location / {
    try_files $uri $uri/ /index.PHP$is_args$args;
    }

location ~ \.PHP$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.PHP;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
}

location ~ /\.ht {
        deny all;
}

location = /favicon.ico {
        log_not_found off; access_log off;
}
location = /robots.txt {
        log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
}
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。