我正在运行具有以下配置的反向代理:
server {
listen 443 ssl http2;
server_name proxy1.mydomain.net;
location / {
proxy_pass https://page1.host.com/;
proxy_redirect https://page1.host.com/ https://proxy1.mydomain.com/;
proxy_redirect https://page2.host.com/ https://proxy2.mydomain.com/;
sub_filter 'page1.host.com' 'proxy1.mydomain.net';
sub_filter 'page2.host.com' 'proxy2.mydomain.net';
}
}
server {
listen 443 ssl http2;
server_name proxy2.mydomain.net;
location / {
proxy_pass https://page2.host.com/;
proxy_redirect https://page1.host.com/ https://proxy1.mydomain.com/;
proxy_redirect https://page2.host.com/ https://proxy2.mydomain.com/;
sub_filter 'page1.host.com' 'proxy1.mydomain.net';
sub_filter 'page2.host.com' 'proxy2.mydomain.net';
}
}
这似乎正确地覆盖了绝对链接,但我无法让第 1 页和第 2 页之间的 302 起作用。例如,加载https://proxy1.mydomain.net/login
返回
HTTP/2 302
server: nginx
location: https://page2.host.com/loginprocess
有没有办法重写location: https://page2.host.com/loginprocess
到location: https://proxy2.mydomain.net/loginprocess
?