小编Cas*_*per的帖子

nginx http 重定向错误地将参数加倍(通过 AWS ELB)

例如,当我浏览

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)

ssl nginx redirect amazon-web-services docker

1
推荐指数
1
解决办法
369
查看次数

标签 统计

amazon-web-services ×1

docker ×1

nginx ×1

redirect ×1

ssl ×1