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

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

转载于:https://blog.51cto.com/13718151/2107264

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值