我在sites-available
中有两个文件,对于在机器上运行的每个网站一个文件。两者都具有相同的代码,只是替换了网站的域名和端口。这两个站点也都链接到sites-enabled
。
reesmorris.co.uk
(效果很好):
# Remove WWW from HTTP
server {
listen 80;
server_name www.reesmorris.co.uk reesmorris.co.uk;
return 301 https://reesmorris.co.uk$request_uri;
}
# Remove WWW from HTTPS
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/reesmorris.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/reesmorris.co.uk/privkey.pem;
server_name www.reesmorris.co.uk;
return 301 https://reesmorris.co.uk$request_uri;
}
# HTTPS request
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name reesmorris.co.uk;
ssl_certificate /etc/letsencrypt/live/reesmorris.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/reesmorris.co.uk/privkey.pem;
location / {
proxy_pass http://127.0.0.1:3000;
include /etc/nginx/proxy_params;
}
}
francescoiacono.co.uk
(具有重定向循环):
# Remove WWW from HTTP
server {
listen 80;
server_name www.francescoiacono.co.uk francescoiacono.co.uk;
return 301 https://francescoiacono.co.uk$request_uri;
}
# Remove WWW from HTTPS
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/francescoiacono.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/francescoiacono.co.uk/privkey.pem;
server_name www.francescoiacono.co.uk;
return 301 https://francescoiacono.co.uk$request_uri;
}
# HTTPS request
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name francescoiacono.co.uk;
ssl_certificate /etc/letsencrypt/live/francescoiacono.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/francescoiacono.co.uk/privkey.pem;
location / {
proxy_pass http://127.0.0.1:4000;
include /etc/nginx/proxy_params;
}
}
为了进行实验,我将损坏的网站的第一个服务器块中的return
值替换为403,即使该网站正在使用HTTPS,该值似乎也仍然显示。此外,完全删除损坏的网站上的第一个服务器块将使该网站完全重定向到已经正常工作的网站。
两个网站都使用CloudFlare进行DNS路由。 CloudFlare在两个网站上都“暂停”,这意味着它仅处理路由,在两个网站中,两个网站到服务器的路由相同,并且AAAA和A记录相同。
我对服务器块不太熟悉,因此,如果有人对正在发生的事情有任何想法,那么将不胜感激。
答案 0 :(得分:0)
通过在CloudFlare DNS中将两个网站“暂停”,似乎可以解决此问题。最初是这样做的,尽管可能没有足够的时间传播。
自从创建此帖子以来,我没有修改代码,尽管我确保两个站点都在CloudFlare上“暂停”了(reesmorris.co.uk
,但francescoiacono.co.uk
不是)-如此看来一直是CloudFlare的配置错误问题。