码迷,mamicode.com
首页 > 其他好文 > 详细

服务器多IP squid代理使用的方法

时间:2018-04-24 17:50:31      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:squid 多ip

1 .安装 squid服务器。squid3 以上版本

修改主配置文件中ip为管理主ip地址

编辑 /etc/squid/squid.conf

http_port x.x.x.x:8000
cache_mgr start@soocol.com
cache_effective_user squid
cache_effective_group squid
cache_mem 128 MB
cache_swap_low 90
cache_swap_high 95
cache deny all
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st "%{Referer}>h" "%{User-Agent}>h" %<A
access_log stdio:/var/log/squid/access.log combined
cache_log /dev/null
via off

visible_hostname Hello World
http_access allow all
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
connect_timeout 5 seconds
peer_connect_timeout 3 seconds
dead_peer_timeout 7 seconds
shutdown_lifetime 2 second
dns_nameservers 10.0.0.2 8.8.8.8
include /etc/squid/multi_ips.conf

配置服务器所有可用IP 到配置文件中。
[majun@proxy1 ~]$cat /etc/squid/multi_ips.conf
acl random11 random 1/11
acl random10 random 1/10
acl random9 random 1/9
acl random8 random 1/8
acl random7 random 1/7
acl random6 random 1/6
acl random5 random 1/5
acl random4 random 1/4
acl random3 random 1/3
acl random2 random 1/2
acl random1 random 1/1
tcp_outgoing_address x.x.x.x random11
tcp_outgoing_address x.x.x.x random10
tcp_outgoing_address x.x.x.x random9
tcp_outgoing_address x.x.x.x random8
tcp_outgoing_address x.x.x.x random7
tcp_outgoing_address x.x.x.x random6
tcp_outgoing_address x.x.x.x random5
tcp_outgoing_address x.x.x.x random4
tcp_outgoing_address x.x.x.x random3
tcp_outgoing_address x.x.x.x random2
tcp_outgoing_address x.x.x.x random1

可以的话最好是IP可以绑定在lo上,不涉及路由问题。

有的时候IP在不同的网卡上需需要添加策略路由。其中IP需要替换为实际服务器中第二块网卡对应的内网ip。
ip ro add default via 10.0.4.1 dev eth1 table 200
ip ru add from 10.0.4.134 table 200
ip ru add from 10.0.4.21 table 200
ip ru add from 10.0.4.22 table 200
ip ru add from 10.0.4.23 table 200
ip ru add from 10.0.4.24 table 200
ip ru add from 10.0.4.25 table 200

服务器多IP squid代理使用的方法

标签:squid 多ip

原文地址:http://blog.51cto.com/13718151/2107264

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!