大家好,
我在 Ubuntu 实例上设置了一个 Nginx Web 服务器。我已将 /etc/nginx/sites-enabled/default 文件配置如下:
server {
listen 80; #listen IPv4
listen [::]:80; #listen IPv6
server_name my.domain.de;
return 301 https://$host$request_uri; #redirect to https://
}
server {
listen 443 ssl spdy; #listen IPv4
listen [::]:443 ssl spdy; #listen IPv6
error_log /var/log/nginx/rocketchat_error.log;
ssl_certificate /etc/letsencrypt/live/my.domain.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/my.domain.de/privkey.pem; # managed by Certbot
ssl_dhparam /etc/nginx/dhparams.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESG$
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 180m;
location / {
proxy_pass http://my.domain.de:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
}
我还通过 http{} 下的 /etc/nginx/nginx.conf 中包含了 /etc/nginx/sites-enabled/default 文件
include /etc/nginx/sites-enabled/default;
我也尝试过
rewrite ^ https://$host$request_uri? permanent;
与
retrun 301 https://my.domain.de$request_uri;
以及任何其他可能的变体。
任何帮助,将不胜感激。
提前致谢
西蒙