我试图弄清楚为什么下面的配置重定向,例如example.com到https://example.com//(注意双尾斜线)。我尝试过使用重写而不是返回301并仍然是同一个问题。先谢谢
我的配置:
server {
listen 80;
return 301 https://$host/$request_uri;
}
server {
listen 443 default_server ssl;
server_name example.com;
ssl_certificate /etc/nginx/ssl/ssl.crt;
ssl_certificate_key /etc/nginx/ssl/ssl.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://192.168.1.2:8000;
}
}
答案 0 :(得分:2)
我认为$request_uri
已经包含斜杠(即,它只是索引页面的'/')所以你可能会改变这一点:
return 301 https://$host/$request_uri;
对此:
return 301 https://$host$request_uri;