The method used by the server multi-IP squid proxy

1. Install squid server. squid3 and above

Modify the ip in the main configuration file to the management main ip address

Edit /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

Configure all available IPs of the server into the configuration file.
[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 xxxx random11
tcp_outgoing_address xxxx random10
tcp_outgoing_address xxxx random9
tcp_outgoing_address xxxx random8
tcp_outgoing_address xxxx random7
tcp_outgoing_address xxxx random6
tcp_outgoing_address xxxx 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

If possible, it is best if the IP can be bound to lo, which does not involve routing issues.

Sometimes IP needs to add policy routing on different network cards. The IP needs to be replaced with the intranet IP corresponding to the second network card in the actual server.
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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324815690&siteId=291194637