Nginx 当proxy_pass返回502错误时,是否有办法得到301错误?
我试图访问/并得到502错误,因为我的/newurl代理返回了一个错误301。Nginx 当proxy_pass返回502错误时,是否有办法得到301错误?,nginx,nginx-config,Nginx,Nginx Config,我试图访问/并得到502错误,因为我的/newurl代理返回了一个错误301。 有什么方法可以代理301错误并将相同内容发送到UI?而不是使用proxy\u pass查看rewrite指令 您正在接收502错误消息,因为代码段中的proxy_pass指令未指向有效的URL location / { proxy_pass /newurl/; } location /newurl { return 303 /old/users; } 我建议共享一个完整的nginx块,这样我们就可以看
有什么方法可以代理301错误并将相同内容发送到UI?而不是使用proxy\u pass查看rewrite指令 您正在接收502错误消息,因为代码段中的proxy_pass指令未指向有效的URL
location / {
proxy_pass /newurl/;
}
location /newurl {
return 303 /old/users;
}
我建议共享一个完整的nginx块,这样我们就可以看到你做错了什么
location / {
rewrite ^ /newurl break;
}
你需要更详细地解释这个问题。原因似乎是您正在重定向到不存在的位置(
/newurl
)。因此301(重定向)=>502(坏网关)。我需要返回301重定向错误,而不是502。
server {
. . .
server_name example.com www.example.com;
rewrite ^/products.html$ /offer.html permanent;
rewrite ^/services.html$ /offer.html permanent;
. . .
}