Nginx 使用上游时出现过多重定向错误

Nginx 使用上游时出现过多重定向错误

我有以下 nginx 配置

upstream test1 {
     server 10.0.1.8:33284;
     server 10.0.3.9:32783;
}

server {
    listen 80;
    server_name test1.example.com;
    rewrite ^ https://test.example.com redirect;
}

server {
      listen 443;
      server_name test.example.com;
      location / {
          proxy_pass http://test1;
          proxy_set_header Host $host;
       }
 }

答案1

我必须设置以下内容

proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;

相关内容