由于新公司需要抓取数据,经常被封掉,而在外面买地代理却不稳定,于是俺就提出了自建代理,没想到北京8M的光纤竟然给了十来个公网ip,于是俺就在一张网卡上配置了十来个公网ip地址,然后安装squid,结果squid设定监听不同地公网ip,然而出去地ip却一直是eth0地,而不是eth0:1地ip地址,于是就按照网上说地添加了:
acl ip1 myip 114.113.221.50
tcp_outgoing_address 114.113.221.50 ip1
这样eth0:1 出去地ip也就是eth0:1地ip地址了
下面为了在一台机器上面启动多个squid于是就制作了多个配置文件,但是一定要把每个配置文件地pid,log,cache等指定到不同地位置,不然会出错地:
# Uncomment and adjust the following to add a disk cache directory.
pid_filename /usr/local/squid/var/logs/squid50.pid
cache_log /usr/local/squid/var/logs/cache50.log
access_log /usr/local/squid/var/logs/access50.log
接下来就是要设定匿名代理不然还是会被封掉:
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
下面贴上整个squid地配置文件:
#
# Recommended minimum configuration:
#
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow all
acl ip1 myip 114.113.221.50
tcp_outgoing_address 114.113.221.50 ip1
# Squid normally listens to port 3128
http_port 114.113.221.50:54321
# Uncomment and adjust the following to add a disk cache directory.
pid_filename /usr/local/squid/var/logs/squid50.pid
cache_log /usr/local/squid/var/logs/cache50.log
access_log /usr/local/squid/var/logs/access50.log
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
原文:http://www.4u45.com/?p=69
没有评论:
发表评论