我很确定这只是一个基本的配置问题。我有一个wordpress多站点的启动和运行,与基本域。我想实现简单的域映射,不幸的是,nginx配置的Wordpress文档非常缺乏。
我在9个月前尝试并成功地使用了吴域映射插件,但这一次它不起作用,我更愿意让它在没有插件的情况下工作(目标是一个低插件WP安装)。
当然,我已经修改了站点部分中的站点URL来测试这一点。
我目前拥有的是:
site1.com (working)
site2.site1.com (working)
site2.com (301 redirect loop)
我想要的是:
site1.com
site2.com
有什么建议,我需要添加到我的Nginx conf文件?我当前的nginx文件与数字海洋码头设置页面的文件大致相同:
server {
listen 80;
listen [::]:80;
server_name *.site1.com site1.com www.site1.com;
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/html;
}
location / {
rewrite ^ https://$host$request_uri? permanent;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
server {
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name site1.com www.site1.com;
index index.php index.html index.htm;
root /var/www/html;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/site1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site1.com/privkey.pem;
include /etc/nginx/conf.d/options-ssl-nginx.conf;
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=31536000; includeSubDomains; preload" always;
# enable strict transport security only if you understand the implications
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;
}
}
更新:
如果我登录并运行nginx
命令,签入nginx,我会得到以下错误消息:编辑--这也发生在工作配置上,因此我猜这可能是一个红色鲱鱼。
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/03/18 10:07:11 [emerg] 29#29: bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
2021/03/18 10:07:11 [emerg] 29#29: bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
2021/03/18 10:07:11 [emerg] 29#29: bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
2021/03/18 10:07:11 [emerg] 29#29: still could not bind()
在容器中,netstat为端口80/443提供了以下内容:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1/nginx: master pro
tcp 0 0 172.18.0.2:38422 199.232.138.132:80 TIME_WAIT -
tcp6 0 0 :::80 :::* LISTEN 1/nginx: master pro
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1/nginx: master pro
tcp6 0 0 :::443 :::* LISTEN 1/nginx: master pro
在容器外,它似乎只正确地运行了一个端口:
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1298/docker-proxy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1313/docker-proxy
编辑(18/3/21):
刚从另一个IP地址的工作备份中恢复,我仍然有这个特定域的问题。有趣的是,我跨越了另一个网站与一个不同的领域和一个是工作的!
我将检查配置,看看其中是否有不同之处,如果没有,我想我需要沿着DNS路由,检查这是否正确地针对我的主机。
发布于 2021-03-18 18:01:38
天哪,那可是个好东西。在这个问题上花了几天的时间,结果发现这是Cloudflare SSL的问题。今天确实注意到了,但没注意到。
事情是指向DNS/SSL的,但不确定它可能是什么。找到了对Cloudflare设置的引用这里,在站点的SSL/TLS设置中,我将加密模式设置为灵活,它们应该已经满了。设置好它,它现在开始工作了。我有种感觉,我已经解决了这个问题,这次最好把它记得更清楚!
https://stackoverflow.com/questions/66679781
复制相似问题