![Nginx 使用上游时出现过多重定向错误](https://linux22.com/image/772388/Nginx%20%E4%BD%BF%E7%94%A8%E4%B8%8A%E6%B8%B8%E6%97%B6%E5%87%BA%E7%8E%B0%E8%BF%87%E5%A4%9A%E9%87%8D%E5%AE%9A%E5%90%91%E9%94%99%E8%AF%AF.png)
我有以下 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;