Total Pageviews

Thursday 25 April 2013

配置pc上的privoxy(或polipo或3proxy)+安卓手机上的opera mobile以使安卓手机上的opera mobile翻墙(原创文章)

首先运行pc上的goagent或shadowsocks或shadowsocks-nodejs或sockstunnel或者ssh tunnel client,(这里以shadowsocks 为例),然后编辑privoxy的配置文件(以管理员身份运行privoxy.exe,然后鼠标右键点击系统托盘处的privoxy的图标,选择edit-main configuration,会弹出config.txt,搜索该txt中的listen-address  127.0.0.1:8118,把它改为listen-address  0.0.0.0:8118,然后加上一行:
forward-socks5   /               127.0.0.1:1080 . (注意1080后有个空格和点。其意思就是启用父socks5代理127.0.0.1:1080)

如果是用polipo,
1. 下载 Polipo,请至其官网http://www.pps.jussieu.fr/%7Ejch/software/polipo/
系统平台     所有
运行环境     所有
官方网站- http://www.pps.jussieu.fr/%7Ejch/software/polipo/,
注意:Polipo 为开放源代码,因此为跨平台移植带来了便利性。官网中已经提供了其他平台移植版本地址,请在 “Contributed binaries and BSD ports” 部分查找。
2. 配置 Polipo
(1). 将 Polipo  解压到任意目录。
(2). 将 config.sample 文件复制为 config 文件,无扩展名。
(3). 编辑 config 文件。
首先找到代理服务器地址及端口部分:
    # proxyAddress = “0.0.0.0″ # IPv4 only
proxyAddress = "127.0.0.1"
将proxyAddress = "127.0.0.1" 注释掉,在其下添加如下所示部分:
    proxyAddress = "0.0.0.0"
    proxyPort = 8123 (8123为polipo.exe的默认端口,无需修改)
然后再查找访问控制部分:
    # allowedClients = “127.0.0.1, 134.157.168.0/24″
将其改为或直接在其下添加:
    #allowedClients = 127.0.0.1
    allowedPorts = 1-65535
本文的目的是所有的客户端电脑均可使用该代理服务器,因此允许的客户端地址为 不限制,开放端口为所有端口。
最后查找代理转发部分:
    socksParentProxy = "127.0.0.1:1080"
    socksProxyType = socks5
上面2行如果是被注释状态,需把他们启用。(其意思就是启用父socks5代理127.0.0.1:1080)
至此,配置部分就完成了,(然后复制c:\windows\system32\cmd.exe文件到c: \program files\polipo目录,双击cmd.exe,在cmd.exe中的提示符后面输入polipo.exe -c config 然后回车,会出现一行内容:
DNS: couldn't open /etc/resolv.conf: No such file or directory.这是正常的。
不要直接打开polipo.exe,直接打开polipo.exe是没用的。你也可以在polipo目录中,用记事本新建一个bat文件,内容为:。
polipo.exe -c config
命名为比如start polipo.bat,以后双击这个bat文件,就把polipo程序启动了,无需在cmd.exe中的提示符后面输入命令,这样做比较方便。 到此设置就完成了).
(https://github.com/jech/polipo/blob/master/INSTALL)

如果是用3proxy, 则3proxy.cfg的内容如下:
nscache 65536
timeouts 1 5 30 60 180 1800 15 60
users "linfeng:CL:iloveu"
auth iponly
allow *  
parent 1000 socks5+ 127.0.0.1 1080  (其意思就是启用父socks5代理127.0.0.1:1080)
proxy -n -a -p3128
 
在命令行里输入 3proxy.exe 3proxy.cfg,回车。
然后设置本地的浏览器的http代理为127.0.0.1:3128,即可翻墙。 (参见
http://briteming.blogspot.co.uk/2013/04/3proxysocks-proxyhttp-proxy.html) 
如果本地的代理客户端是http proxy,比如goagent,wallproxy,   则上面的socks5+改为http,后面的
端口1080改为本地的http代理客户端 的端口,比如8087 
其意思就是启用父http代理127.0.0.1:8087
 

 如果pc上运行的代理客户端是goagent+privoxy,则以管理员身份运行privoxy.exe,然后鼠标右键点击系统托盘处的privoxy的图标,选择edit-main configuration,会弹出config.txt,搜索该txt中的listen-address  127.0.0.1:8118,把它改为listen-address  0.0.0.0:8118,然后加上一行:
forward  /   127.0.0.1:8087 (其意思就是启用父http代理127.0.0.1:8087)

 如果pc上运行的代理客户端是goagent+polipo,则查找代理转发部分:
#parentProxy = "squid.example.org:3128",在其下面加一行:
parentProxy = "127.0.0.1:8087" ( 其意思就是启用父http代理127.0.0.1:8087)

 至于安卓手机中,能设置http proxy的浏览器建议使用opera mobile,具体参见http://briteming.blogspot.kr/2013/02/androidhttp-opera-mobile.html,注意:要把http server栏设置为你的pc在无线局域网中的ip地址,我的为192.168.1.100,端口号则设为8118或8123或3128(具体写为192.168.1.100:8118或192.168.1.100:8123或192.168.1.100:3128),依你在pc上是使用privoxy还是polipo还是3proxy来定。https server栏无需填写。至于如何获悉你的pc在无线局域网中的ip地址,请参见http://briteming.blogspot.kr/2013/04/ip.html,这样即可使安卓手机上的opera mobile翻墙了。

 以上的代理客户端程序goagent或shadowsocks或shadowsocks-nodejs或sockstunnel或ssh tunnel client,无需 额外修改其配置文件。
-------------------------------

Proxy管理器3proxy


3proxy是款功能强大的代理软件,本身支持HTTP及Socks5代理,同时还支持将HTTP代理转为socks5代理,及多代理负载均衡。

1
yum install 3proxy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#后台进程
daemon
#DNS服务器
nserver 8.8.8.8
#DNS缓存
nscache 65536
#超时
timeouts 1 5 30 60 180 1800 15 60
#日志
log /var/log/3proxy.log
logformat "- +_L%t.%.  %N.%p %E %U %C:%c %R:%r %O %I %h %T"
rotate 30
#用户 CL明文密码
users user1:CL:pwd user2:CL:pwd
#权限控制参数
#allow <userlist> <sourcelist> <targetlist> <targetportlist> <commandlist> <weekdaylist> <timeperiodlist>
#deny <userlist> <sourcelist> <targetlist> <weekdaylist> <timeperiodlist>
 
#开启socks和http代理,指定监听端口和出口IP
auth iponly strong
allow user1,user2
allow * 192.168.0.0/16 *
socks -p1080 -e192.168.1.1
socks -p1081 -e192.168.1.2
proxy -p8080 -e192.168.1.1
proxy -p8081 -e192.168.1.2
flush
 
#开启HTTP代理,端口3128,轮换出口IP
auth iponly
allow *
parent 500 http 192.168.1.2 0
parent 500 http 192.168.1.1 0
proxy -p3128
flush
 
#开启上层代理,HTTP端口1234,轮换上层socks5代理
auth iponly
allow *
parent 500 socks5 192.168.1.1 7777
parent 500 socks5 192.168.1.1 7070
parent 500 connect 192.168.1.1 3128
proxy -p1234
flush

启动:

1
3proxy config.cfg

命令行工具:

1
socks -d -iIP 192.168.1.1 -pPORT 1080 -eIP 192.168.1.1

Windows下Bin目录新建配置文件3proxy.cfg,安装为系统服务并启动:

1
3proxy.exe --install
-------------------

相关帖子:https://briteming.blogspot.com/2013/01/3proxy.html

-------------

在Mac上,使用polipo

通过Homebrew安装polipo并在~/.polipo新建配置文件:

$ brew install polipo
$ vi ~/.polipo
socksParentProxy = "127.0.0.1:1080"
socksProxyType = "socks5"
proxyAddress = "127.0.0.1"
proxyPort = 8080
localDocumentRoot = "~/.www/"
dnsNameServer = "127.0.0.1"
dnsUseGethostbyname = false
dnsMaxTimeout = 1s
dnsQueryIPv6 = false
cacheIsShared = true
diskCacheRoot = ""
disableVia = true
censorReferer = false
tunnelAllowedPorts = 1-65535
disableLocalInterface = true

设置开机启动:

$ ln -sfv /usr/local/opt/polipo/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist

创建~/.www目录,并使用Mono_Pac项目生成符合自己需求的Pac文件:

$ mkdir ~/.www
$ git clone https://github.com/blackgear/mono_pac.git
$ cd ./src
$ python ./make.py -p "PROXY 127.0.0.1:8080" -o ~/.www/proxy.pac

进入系统偏好设置-网络-高级-代理,将自动代理配置URL设置为http://127.0.0.1:8080/proxy.pac使GUI程序通过Pac决定是否走代理。

修改~/.bash_profile,加入与代理有关的环境变量使得命令行程序通过代理连接网络:

$ vi ~/.bash_profile
export all_proxy="http://127.0.0.1:8080"
export http_proxy=$all_proxy
export https_proxy=$all_proxy
export ftp_proxy=$all_proxy
export rsync_proxy=$all_proxy

通过Homebrew安装socat并修改~/.ssh/config,使ssh连接通过代理进行连接:

$ brew install socat
$ vi ~/.ssh/config
Host *
    ServerAliveInterval 5
    ServerAliveCountMax 3
    ControlMaster auto
    ControlPath ~/.ssh/%h-%p-%r
    ControlPersist yes
    ProxyCommand /usr/local/bin/socat - proxy:localhost:%h:%p

修改~/.gitconfig使git通过代理进行连接:

$ cat ~/.gitconfig
[https]
    proxy = 127.0.0.1:8080
[http]
    proxy = 127.0.0.1:8080