privoxy将socks代理转为http代理
有些软件不支持socks代理,只支持http代理。不像火狐那样都支持,于是有的时候要建http代理。如Jenkins代理,只支持http代理模式。
如果有socks代理,想做一个http代理的话,这篇文章可能会有帮助。
安装privoxy
Privoxy is a non-caching web proxy with advanced filtering capabilities for enhancing privacy, modifying web page data and HTTP headers, controlling access, and removing ads and other obnoxious Internet junk. Privoxy has a flexible configuration and can be customized to suit individual needs and tastes. It has application for both stand-alone systems and multi-user networks.
很强大的工具。有兴趣的自己去啃啃哈。官网http://www.privoxy.org/
1 | yum install privoxy |
直接yum安装了,编译的麻烦。要先添加repo源。
建立socks代理
我这里是以ssh来建立的。
1 | ssh – f – C2qTnN – D 1080 ttlsa @ www . ttlsa . com |
www.ttlsa.com位于墙外。
在本地建立起127.0.0.1:1080的socks代理。
配置privoxy
1 2 3 | # vim /etc/privoxy/config添加下面这一行 forward – socks5 / 127.0.0.1 : 1080 . |
其它的不用改了。
forward-socks5代表转发到socks5代理,/代表所有的URL都转发(也可以在这里写url patten),127.0.0.1:1080是socks代理地址,.将请求不转发到另一个http代理,而是直接发送到web服务器。
启动
/etc/init.d/privoxy restart
服务监听在本地127.0.0.1:8118上。如果需要其它设备使用该代理,更改配置文件listen-address参数。
测试
1 2 3 4 5 6 7 | $ curl – x 127.0.0.1 : 8118 http : //www.google.com < HTML > < HEAD > < meta http – equiv = “content-type” content = “text/html;charset=utf-8” > < TITLE > 302 Moved < / TITLE > < / HEAD > < BODY > < H1 > 302 Moved < / H1 > The document has moved < A HREF = “http://www.google.com.hk/?gfe_rd=cr&ei=bUcHV_jWOpTM8gfz7qPADA” > here < / A > . < / BODY > < / HTML > |
全球可信CA机构