本文及资源最后更新时间 2022-05-03 by sky995
之前有人分享过php的,但效率有点低。
这个是纯NGINX的任意反向代理
使用访问地址示例:
http://127.0.0.1/https://hostloc.com
效果如下图:
server里面的写了baidu
百度是默认的。
http://127.0.0.1/https://hostloc.com
网址后面那个是反代地址。
不用改代码输入
http://127.0.0.1/https://www.163.com 就反代163了。
这代码一会baidu一会$custom_host1 3 5,有啥用最后好像就用了3?
都有用
$custom_host5 = https://
判断是否https
proxy_set_header Host $custom_host2;
获取域名
proxy_pass $custom_host;
反代地址
没有配置301追随。一会更新一下就可以了,或者你自己加上:proxy_redirect off;
想用一台服务器反代另一台服务器所有的访问 要怎么写配置呢
直接haproxy 4 层,或者iptables转发简单一点
反代中出现
ip138显示的是本地ip,https://www.whatismyip.com/ 依然502,https://www.whatismyip.com.tw/ 依然双ip …
https://www.whatismyip.com/ 这个502是因为套了CF
p138显示的是本地ip 修改
sub_filter “\”//” ‘”$current$host/https://’;
sub_filter ‘”/’ ‘”$current$host/$custom_host/’;
https://www.whatismyip.com.tw/ 依然双ip
注释
# proxy_set_header x-forwarded-for $remote_addr;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
再加两行配置就支持websocket
0localhost_80.conf.zip(1.8 KB)