privoxy自动请求转发到多个网络

有些时候我们需要通过不同的代理访问不同资源,比如某些ip或域名走本地网络,某些ip或域名走不可描述的代理等。当然这只是举个栗子!

我要解决的问题是:我的内网机器没有internet访问权限,但是我的应用程序有部分请求是要访问intranet网络,而部分请求要访问internet网络。所以我必须得有一个软件或工具来做这个区分或者说是请求的转发。那么privoxy就闪亮登场了。
网络环境是这样子的

1.安装privoxy

这个就不说了

2.修改配置

主配置文件 /etc/privoxy/config 增加一条配置:
actionsfile usr.proxy
例如:

actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action   # Main actions file
actionsfile user.action      # User customizations
actionsfile usr.proxy

3.编辑usr.proxy文件

在/etc/privoxy/目录下创建usr.proxy文件

{{alias}}
#直连方式,也就是说让请求走本地网络
direct      = +forward-override{forward .}
#请求转发到代理机器,请求可以走到internet网络
proxy       = +forward-override{forward 10.0.5.10:8118}
#请求转发到代理机器,请求可以走到不可描述的地方去
#1080端口代表的是什么不可描述的东西,就不多说了。
#值得注意的是1080走的socks5代理,所以是forward-socks5 10.0.5.10:1080 .(后面的这个点可不能丢哦)
over_wall_proxy       = +forward-override{forward-socks5 10.0.5.10:1080 .}
default     = proxy
#==========默认代理==========
{default}
/
#==========直接连接==========
{direct} 
10.0.5.10
127.0.0.1
localhost
.api.com
{proxy}
#==========不可描述的代理==========
{over_wall_proxy}
.google.
.github.com
.githubusercontent.
.github.cnpmjs.org

猜你喜欢

转载自www.cnblogs.com/calvinK/p/9083901.html
今日推荐