在命令行中使用 http 代理包装 tor socks 代理 [英] Wrap tor socks proxy with http proxy in command line

查看:124
本文介绍了在命令行中使用 http 代理包装 tor socks 代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过 apt 安装了 tor 并且它正在监听端口号 9050

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       

由于tor是socks代理,我想使用它的http代理,我通过apt安装了polipo并配置如下

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

然后我重新启动了 torpolipo 服务.polipo 日志说它正在侦听端口号 8123,这听起来很奇怪!!!

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

我知道我必须为 http_proxyhttps_proxy 设置变量.所以,

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

但是,wget 命令无法访问该站点并出现以下错误

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.

配置有什么问题?我需要找到一种方法让 wget 在 bash 脚本中使用它.

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/

推荐答案

你应该改变:

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 代理.

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

如果你从 apt 安装 Tor,你也可以尝试:

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

torify wget https://torproject.org

这将强制您通过它运行的任何程序使用 Tor 的 SOCKS 代理.

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

或者,只需使用内置 SOCKS 支持的 curl:

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

curl --socks5-hostname 127.0.0.1:9050 https://torproject.org/

这篇关于在命令行中使用 http 代理包装 tor socks 代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆