3proxy是一个由俄罗斯人开发的多平台代理软件,支持http/https/ftp/socks4/socks5/socks4a/socks5a等多种代理方式。(又是俄罗斯人)
同时它还支持将HTTP代理转为socks5代理,及多代理负载均衡。
我这里使用的平台是CentOS6
安装方式用的是yum epel源安装
# yum install 3proxy -y # rpm -ql 3proxy #可以看到安装后生成哪些文件 和 具体路径
配置文件路径: /etc/3proxy.cfg
#配置文件大概参数 nserver 114.114.115.115 #代理如果需要服务器解析,那么使用该dns解析并代理 nscache 65536 #域名解析最大的缓存条目 默认即可 timeouts 1 5 30 60 180 1800 10 60 #timeouts <BYTE_SHORT> <BYTE_LONG> <STRING_SHORT> <STRING_LONG> <CONNECTION_SHORT> <CONNECTION_LONG> <DNS> <CHAIN> 各项连接选项的超时时间 daemon #作为守护进程运行 log /var/log/3proxy/3proxy.log D #日志路径 参数D 是每天记录单独的日志文件 logformat "-%m.%d. %H:%M:%S %N.%p %E %U %C:%c %R:%r ↓%O ↑%I %h %T" #日志内容格式 rotate 30 #最大保存最新的30个日志文件 users user:CL:pass user2:CL:pass # 代理认证的用户名和密码 # CL:代表明文密码 # CR:密码使用密文加密 # NT:密文加密 auth strong #代理认证类型 # none:不需要认证(默认类型) # iponly:根据源IP地址进行ACL控制 # username:只验证用户名,用于Socks4代理 # nbname:认证基于NetBIOS (Windows系统) # strong:基于弹窗用户名/密码认证,支持HTTP/POP3/FTP/SOCKSv5的代理类型 # cache:认证缓存,依赖authcache选项 ##### auth strong / auth iponly atrong 可以同时开启多项认证方式 allow user #allow选项 # allow <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> <weekdayslist> <timeperiodslist> allow选项的参数,选项支持 *匹配 # deny <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> <weekdayslist> <timeperiodslist> deny选项的参数,选项支持 *匹配 #Operation is one of: 代理连接方式支持以下方式 # CONNECT - establish outgoing TCP connection # BIND - bind TCP port for listening # UDPASSOC - make UDP association # ICMPASSOC - make ICMP association (for future use) # HTTP_GET - HTTP GET request # HTTP_PUT - HTTP PUT request # HTTP_POST - HTTP POST request # HTTP_HEAD - HTTP HEAD request # HTTP_CONNECT - HTTP CONNECT request # HTTP_OTHER - over HTTP request # HTTP - matches any HTTP request except HTTP_CONNECT # HTTPS - same as HTTP_CONNECT # FTP_GET - FTP get request # FTP_PUT - FTP put request # FTP_LIST - FTP list request # FTP_DATA - FTP data connection. Note: FTP_DATA requires access to dynamic # non-ptivileged (1024-65535) ports on remote side. # FTP - matches any FTP/FTP Data request # ADMIN - access to administration interface proxy -n -p60000 #一个HTTP代理 端口是60000 -n:关闭windows NTML验证 parent 1000 connect+ 0.0.0.0 60000 #向后代理,可以向后端转换代理类型,以及负载平衡 (注意:此种方式只适用于认证方式为 iponly或strong模式)权重weight为1000均分,所以你如果只有一个上级代理,那么权重就设置为1000吧,如果有多个代理,你可以分别设置300/700 300/400/300 500/500 等,这样才会在一组父代理中按照权重均分。 # parent <weight> <type> <ip> <port> <username> <password> 选项参数 #type is one of: # tcp - simply redirect connection. TCP is always last in chain. # http - redirect to HTTP proxy. HTTP is always last chain. # pop3 - redirect to POP3 proxy (only local redirection is supported, can not be used for chaining) # ftp - redirect to FTP proxy (only local redirection is supported, can not be used for chaining) # connect - parent is HTTP CONNECT method proxy # connect+ - parent is HTTP CONNECT proxy with name resolution # socks4 - parent is SOCKSv4 proxy # socks4+ - parent is SOCKSv4 proxy with name resolution (SOCKSv4a) # socks5 - parent is SOCKSv5 proxy # socks5+ - parent is SOCKSv5 proxy with name resolution # socks4b - parent is SOCKS4b (broken SOCKSv4 implementation with shortened server reply. I never saw this kind ofservers byt they say there are). Normally you should not use this option. Do not mess this option with SOCKSv4a (socks4+). # socks5b - parent is SOCKS5b (broken SOCKSv5 implementation with shortened server reply. I think you will never find it useful). Never use this option unless you know exactly you need it. # admin - redirect request to local ’admin’ service (with -s parameter). Use "+" proxy only with "fakeresolve" option nolog #低于某一项代理方式可以设置无需记录日志 #bandlimin <rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> 入相带宽限制 #bandlimout <rate> <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> 出向带宽限制 #nobandlimin <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> 入相带宽不限制 #nobandlimout <userlist> <sourcelist> <targetlist> <targetportlist> <operationlist> 出向带宽不限制 flush #用来划分各代理区域的配置参数,比如你可以在配置文件中配置两个代理 一个HTTP代理 一个Socks5代理 那么到第二段Socks5代理的时候,由于配置文件语法格式的限制,所以需要隔离上一个代理选项的配置参数,这里就需要 flash选项来刷新下端即将出现的参数,用来覆盖上端重复的参数。 external 0.0.0.0 #代理服务器向外转发的时候绑定的IP地址 internal 223.255.7.250 #代理本地监听的IP地址
#后台进程
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
别人的配置文件,可以参照参照。
转载于:https://blog.51cto.com/professor/1701735