瑞瑞哥的博客

Ubuntu 16.04.02LTS 安装3proxy

Ubuntu 16.04.02LTS 安装3proxy

3proxy是俄罗斯老毛子写的一个很厉害的代理软件,功能强大,支持各种协议,支持上游代理,支持密码认证等功能,而且资源占用较小。我原来使用polipo,现在已经切换到3proxy了。问题是我按照3proxy官方文档里的安装教程,根本装不上,因此我写了这个教程来记录一下安装过程。

安装

有个哥们在github上搞了个一键安装脚本,我这个教程是基于他这个脚本的。问题是脚本是基于Ubuntu14.04的,其中将3proxy注册为服务的命令在Ubuntu14.04下是可以的,在16.04下是不可以的。因此我fork了一份项目,增加了几个小配置项,并且使用systemd管理服务。如果你自己会在Ubuntu16.04上注册服务,你也可以直接用原版脚本,然后自己手动注册服务。

如果你是Ubuntu 14.04:

1
2
3
wget --no-check-certificate https://raw.github.com/barankilic/3proxy/master/3proxyinstaller.sh
chmod +x 3proxyinstaller.sh
./3proxyinstaller.sh

如果你是Ubuntu 16.04:

1
2
3
wget --no-check-certificate https://raw.github.com/ruiruige/3proxy/master/3proxyinstaller.sh
chmod +x 3proxyinstaller.sh
./3proxyinstaller.sh

修改配置文件

配置文件还是需要修改一下的,首先打开/etc/3proxy/3proxy.cfg

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
# Specify valid name servers. You can locate them on your VPS in /etc/resolv.conf
#
nserver 8.8.8.8
nserver 8.8.4.4
#Leave default cache size for DNS requests:
nscache 65536
#Leave default timeout as well:
timeouts 1 5 30 60 180 1800 15 60
#If your server has several IP-addresses, you need to provide an external one
#Alternatively, you may ignore this line
#external YOURSERVERIP
#If you ignore this line, proxy will listen all the server's IP-addresses
#internal YOURSERVERIP
#Create users proxyuser1 and proxyuser2 and specify a password
users $/etc/3proxy/.proxyauth
#Specify daemon as a start mode
daemon
#Logs path and log format. Creation date will be added to a log name
#log /dev/null
log /var/log/3proxy/3proxy.log
logformat "- +_L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
#Compress logs using gzip
archiver gz /usr/bin/gzip %F
#store the logs for 30 days
rotate 1
#enable strong authorization. To disable authentication, simply change to 'auth none'
#added authentication cachiing to make life easier
authcache user 60
auth strong cache
#restrict access for ports via http(s)-proxy and deny access to local interfaces
#
deny * * 127.0.0.1,192.168.1.1
#allow * * * 80-88,8080-8088 HTTP
#allow * * * 443,8443 HTTPS
allow * * * 1-65535 HTTP
allow * * * 1-65535 HTTPS
# run http-proxy ... without ntlm-authorization, complete anonymity and port ...
proxy -n -p3128 -a
#Enable admin web-ui on specified port
# admin -p3200

如果需要设置父代理,可以加上parent 1000 socks5 127.0.0.1 7070

具体可以看这里

然后设置用户的账号密码:

1
2
3
4
## addusers in this format:
#user:CL:password
##see for documentation: http://www.3proxy.ru/howtoe.asp#USERS
proxyuser1:CL:StrongPasswordforUser

启动

1
service 3proxy start