注意:请参阅下面的更新!
我有一个关于两个域的 Nginx 设置,example1.org
并且example2.org
它们都在同一个实例中处理。
我的问题是example2.org
,我想http://www.example2.org
重定向到https://example2.org
,但是当我输入http://www.example2.org
浏览器时,我总是以“隐私错误 - 不安全”告终,其中列出了example1.org
.
问题似乎是default server
解决时“获胜”的部分,据我http://www.example2.org
所知,不应该发生,而且 des 似乎没有发生
首先default.conf
,example1.org
我有:
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
ssl_certificate /etc/letsencrypt/live/example1.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example1.org/privkey.pem; # managed by Certbot
ssl_session_tickets off;
return 302 http://$host$request_uri;
}
然后example2.org.conf
我有
server {
server_name www.example2.org;
return 301 https://example2.org$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example2.org;
root /opt/web-apps/example2.org/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)
ssl_certificate /etc/letsencrypt/example2.org/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/example2.org/example2.org.key;
include /etc/nginx/snippets/ssl-params.conf;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2371;
}
location ~ /.well-known {
allow all;
}
client_max_body_size 50m;
}
对我遗漏/做错了什么有什么建议吗?
干杯!
更新:
浏览器保留自己的 HSTS 缓存,这会把事情搞砸。不幸的是,似乎没有办法为特定的子域禁用此服务器端,例如“www”。...