Nginx反向代理来简单镜像 HTTP(S)网站
一、反向代理IP端口
location / {
proxy_pass http://123.123.123.123:1000; # 目标 IP 和端口
proxy_set_header Host $host; # 设置 Host 头部
proxy_set_header X-Real-IP $remote_addr; # 设置客户端 IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 传递原始 IP
proxy_set_header X-Forwarded-Proto $scheme; # 传递协议(http 或 https)
}
二、反向代理网站
if ( $scheme = http ){
return 301 https://$server_name$request_uri;
}
if ($http_user_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) {
return 403;
}
location / {
sub_filter www.baidu.com www.abc.com;
sub_filter_once off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Referer https://www.baidu.com;
proxy_set_header Host www.baidu.com;
proxy_pass https://www.baidu.com;
proxy_set_header Accept-Encoding "";
}
上一篇
X-UI解锁流媒体