Wrap tor socks proxy with http proxy in command li

2019-05-31 08:14发布

I have installed tor via apt and it is listening on port number 9050

# netstat -ntlup | grep tor
tcp        0      0 127.0.0.1:9050          0.0.0.0:*               LISTEN      13566/tor       

Since tor is a socks proxy and I want to use that an http proxy, I installed polipo via apt and configured that as below

# cat /etc/polipo/config 
logSyslog = true
logFile = /var/log/polipo/polipo.log
allowedClients = 127.0.0.1, 192.168.1.0/24 # Expose your network (modify accordingly)
socksParentProxy = "localhost:9050"
socksProxyType = socks5
proxyAddress = "0.0.0.0"    # IPv4 only

Then I restarted tor and polipo services. The polipo log says it is listening on port number 8123 which sounds odd!!!

I know I have to set the variables for http_proxy and https_proxy. So,

# export http_proxy=127.0.0.1:9050 https_proxy=127.0.0.1:9050

However, the wget command is unable to reach the site with the following error

 # wget https://torproject.org
 --2018-03-29 21:14:28--  https://torproject.org/
Connecting to 127.0.0.1:9050... connected.
Proxy tunneling failed: Tor is not an HTTP ProxyUnable to establish SSL connection.

What is wrong with the config? I need to find a way for wget to use that in a bash script.

[1] https://www.marcus-povey.co.uk/2016/03/24/using-tor-as-a-http-proxy/

标签: proxy tor socks
1条回答
别忘想泡老子
2楼-- · 2019-05-31 08:34

You should change:

export http_proxy=127.0.0.1:9050 https_proxy=127.0.0.1:9050

to

export http_proxy=127.0.0.1:8123 https_proxy=127.0.0.1:8123

You set the proxy environment variables to Tor's SOCKS proxy, not the polipo HTTP proxy.

If you installed Tor from apt, you could also try:

torify wget https://torproject.org

This will force whatever program you run through it to use Tor's SOCKS proxy.

Or, just use curl which has built in SOCKS support:

curl --socks5-hostname 127.0.0.1:9050 https://torproject.org/
查看更多
登录 后发表回答