为什么当我点击登录或注销按钮时总是重定向到原始网站/代理网站
server {
listen 80;
server_name abcd.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/doremi/abcd.crt;
ssl_certificate_key /etc/ssl/doremi/private.key;
server_name abcd.com;
location / {
proxy_pass http://xyz.vip;
proxy_set_header Accept-Encoding "";
sub_filter 'http://xyz.vip' 'https://abcd.com';
sub_filter 'http://xyz.vip/dashboard' 'https://abcd.com/dashboard';
sub_filter_once off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
每当我点击 abcd.com 上的登录按钮时,总是转到 xyz.vip,谢谢你的帮助
因此我尝试 curl abcd.com 并得到以下结果,仍然无法让 xyz.vip 变成 abcd.com
curl -vv http://abcd.com/main
< HTTP/1.1 302 Found
< Server: nginx/1.14.0 (Ubuntu)
< Date: Wed, 30 Dec 2020 05:48:58 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< location: http://xyz.vip
> <!DOCTYPE html> <html>
> <head>
> <meta charset="UTF-8" />
> <meta http-equiv="refresh" content="0;url='http://xyz.vip'" />
>
> <title>Redirecting to http://xyz.vip</title>
> </head>
> <body>
> Redirecting to <a href="http://xyz.vip">http://xyz.vip</a>.
> </body>
答案1
你可以尝试几件事吗?将其添加到你的位置
proxy_set_header 主机 $host;
或者
返回 301 https://abcd$request_uri;
而不是 https://$server_name$request_uri;
我没有使用 sub_filter 选项,但运行良好。