在命令行中使用 http 代理包装 tor socks 代理
Wrap tor socks proxy with http proxy in command line
我已经通过 apt
安装了 tor
,它正在侦听端口号 9050
# netstat -ntlup | grep tor
tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN 13566/tor
由于 tor 是一个 socks 代理,我想使用它作为一个 http 代理,我通过 apt
安装了 polipo
并配置如下
# 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
然后我重新启动了 tor
和 polipo
服务。 polipo
日志说它正在侦听端口号 8123,这听起来很奇怪!!!
我知道我必须为 http_proxy
和 https_proxy
设置变量。所以,
# export http_proxy=127.0.0.1:9050 https_proxy=127.0.0.1:9050
但是,wget
命令无法访问站点,出现以下错误
# 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.
配置有什么问题?我需要找到一种方法让 wget
在 bash 脚本中使用它。
[1] https://www.marcus-povey.co.uk/2016/03/24/using-tor-as-a-http-proxy/
你应该改变:
export http_proxy=127.0.0.1:9050 https_proxy=127.0.0.1:9050
到
export http_proxy=127.0.0.1:8123 https_proxy=127.0.0.1:8123
您将代理环境变量设置为 Tor 的 SOCKS 代理,而不是 polipo HTTP 代理。
如果您从 apt
安装了 Tor,您也可以尝试:
torify wget https://torproject.org
这将强制您 运行 通过它的任何程序使用 Tor 的 SOCKS 代理。
或者,只需使用内置 SOCKS 支持的 curl:
curl --socks5-hostname 127.0.0.1:9050 https://torproject.org/
我已经通过 apt
安装了 tor
,它正在侦听端口号 9050
# netstat -ntlup | grep tor
tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN 13566/tor
由于 tor 是一个 socks 代理,我想使用它作为一个 http 代理,我通过 apt
安装了 polipo
并配置如下
# 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
然后我重新启动了 tor
和 polipo
服务。 polipo
日志说它正在侦听端口号 8123,这听起来很奇怪!!!
我知道我必须为 http_proxy
和 https_proxy
设置变量。所以,
# export http_proxy=127.0.0.1:9050 https_proxy=127.0.0.1:9050
但是,wget
命令无法访问站点,出现以下错误
# 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.
配置有什么问题?我需要找到一种方法让 wget
在 bash 脚本中使用它。
[1] https://www.marcus-povey.co.uk/2016/03/24/using-tor-as-a-http-proxy/
你应该改变:
export http_proxy=127.0.0.1:9050 https_proxy=127.0.0.1:9050
到
export http_proxy=127.0.0.1:8123 https_proxy=127.0.0.1:8123
您将代理环境变量设置为 Tor 的 SOCKS 代理,而不是 polipo HTTP 代理。
如果您从 apt
安装了 Tor,您也可以尝试:
torify wget https://torproject.org
这将强制您 运行 通过它的任何程序使用 Tor 的 SOCKS 代理。
或者,只需使用内置 SOCKS 支持的 curl:
curl --socks5-hostname 127.0.0.1:9050 https://torproject.org/