squid在做多域名时,cache_peer的设置为:

cache_peer 10.11.12.107 parent 80 0 no-query originserver round-robin name=web01
cache_peer 10.11.12.126 parent 80 0 no-query originserver round-robin name=web02
cache_peer 10.11.12.113 parent 80 0 no-query originserver round-robin name=web03

cache_peer 122.227.129.122 parent 80 0 no-query originserver name=media

cache_peer_domain media media2.ihompy.com
cache_peer_domain web01 www.ihompy.com
cache_peer_domain web02 www.ihompy.com
cache_peer_domain web03 www.ihompy.com

就可以了,但是如果web01-web03是通配域名.ihompy.com,上面的就不行了。

可用如下配置:

visible_hostname squid1.ihompy.com
http_port 80 accel vhost vport

cache_peer 10.11.12.107 parent 80 0 no-query originserver round-robin name=web01
cache_peer 10.11.12.126 parent 80 0 no-query originserver round-robin name=web02
cache_peer 10.11.12.113 parent 80 0 no-query originserver round-robin name=web03

cache_peer 122.227.129.122 parent 80 0 no-query originserver name=media

cache_peer_domain media media2.ihompy.com

cache_peer_domain web01 !media2.ihompy.com
cache_peer_domain web02 !media2.ihompy.com
cache_peer_domain web03 !media2.ihompy.com

cache_peer_domain web01 .ihompy.com
cache_peer_domain web02 .ihompy.com
cache_peer_domain web03 .ihompy.com

cache_effective_user squid
cache_effective_group squid

#error_directory /usr/local/squid3/share/errors/Simplify_Chinese
#icon_directory /usr/local/squid3/share/icons
#mime_table /usr/local/squid3/etc/mime.conf


#acl all src 0.0.0.0/0.0.0.0
http_access allow all

acl QueryString url_regex .php?
acl QueryString url_regex .xml?
no_cache deny QueryString

negative_ttl 30 seconds

cache_log /var/log/squid/cache.log
cache_access_log /var/log/squid/access.log
cache_store_log /var/log/squid/store.log

cache_dir ufs /usr/local/squid/var/cache 20000 16 256
cache_mem 3000 MB

maximum_object_size 320010 KB
maximum_object_size_in_memory 100 KB

memory_pools on
memory_pools_limit 64 MB

forwarded_for on
log_icp_queries off

via on
httpd_suppress_version_string off

ie_refresh off
tcp_recv_bufsize 32 KB

memory_replacement_policy lru

dns_nameservers 10.11.12.130 10.11.12.131
cache_mgr admin@ihompy.com