例如,当我浏览
http://example.com/foo?x=1&y=2
nginx 将我重定向到
https://example.com/foo?x=1&y=2?x=1&y=2
现在,如果我继续重定向,我会得到
https://example.com/foo?x=1&y=2?x=1&y=2?x=1&y=2?x=1&y=2
它不断加倍参数,不知道我做错了什么。
我的 nginx 配置:
server {
listen 80;
listen 443 ssl;
server_name {{ .SERVER_NAME }} www.{{ .SERVER_NAME }};
ssl_certificate /etc/ssl/nginx.crt;
ssl_certificate_key /etc/ssl/nginx.key;
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$server_name$REQUEST_URI permanent;
}
# Nginx will reject anything not matching /
location / {
# Reject requests with unsupported HTTP method
if ($request_method !~ ^(GET|POST|HEAD|OPTIONS|PUT|DELETE|PATCH)$) {
return 405;
}
# Only requests matching the whitelist expectations will
# get sent to the application server …
Run Code Online (Sandbox Code Playgroud)