nginx 反向代理 - 仿站,镜像站等
2022-07-14 本文已影响0人
Renew全栈工程师
www.xxx.com 反向代理到 www.baidu.com,并且反向cookie,遇到header location 也跳转到当前域名下,如果需要替换里面文本,也可以用nginx sub_filter 指令进行内容替换
server {
listen 80;
index index.html index.htm;
server_name www.xxx.com;
location / {
proxy_cookie_domain ~\.?baidu.com $host;
proxy_pass https://www.baidu.com$request_uri;
proxy_redirect ~^https://www.baidu.com(.*) http://$server_name$1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host www.baidu.com;
resolver 8.8.8.8;
}
}