服务器多IP squid代理使用的方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了服务器多IP squid代理使用的方法相关的知识,希望对你有一定的参考价值。
1 .安装 squid服务器。squid3 以上版本
修改主配置文件中ip为管理主ip地址
编辑 /etc/squid/squid.conf
http_port x.x.x.x:8000
cache_mgr [email protected]
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 到配置文件中。
[[email protected] ~]$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代理使用的方法的主要内容,如果未能解决你的问题,请参考以下文章