首页 > 能通过配置让nginx/apache/or其他 通过代理进行反代么(win)

能通过配置让nginx/apache/or其他 通过代理进行反代么(win)

因为工作的环境有很多个版本,使用的是相同的域名,通过host切换来查看
有的甚至还要通过公司的squid代理才能访问得到,非常麻烦

所以我准备用nginx进行反代,普通的都很快就配置好了,唯独需要HTTP代理的我找不到可用的参数进行

我用了如下的配置

sub_filter real.cn demo.cn;
sub_filter_once off;
sub_filter_types *;
location / {
proxy_pass http://xxx.xxx.xxx.xxx:8080;
proxy_set_header Host image.real.cn;
proxy_set_header X-Real-IP 我的IP;
proxy_set_header X-Forwarded-For 我的IP;
}

但是没用,squid会报:

The following error was encountered while trying to retrieve the URL: /
Invalid URL

抓包发现nginx proxy_pass请求是

GET / HTTP/1.1

所以报错了,但是$request_uri又改不了...

我又看了一下apache的模块,mod_proxy里的ProxyRemote只能在使用apache当正向代理时有用,所以也没法用。

而squid
我没接触过,粗略看了一下配置反代和配置二级代理,都用的cache_peer,不知道能不能实现。

因为是在win环境下,所以,也不能用iptables这等神器...

所以来这问下各位,通过配置能让一个webserver通过代理进行反代么?

【热门文章】
【热门文章】