「お前のcacheはおれのもの、俺のcacheも俺の物」これがsquidのsiblingの基本。
squidはsiblingの設定をしていると、次のように動作する。
- 自分のcacheを確認。あったらクライアントに返す。
- なかったらsiblingに問い合わせ。あったら自分にcacheして、クライアントに返す。
- それでもなかったらoriginに問い合わせ。あったら自分にcacheして、クライアントに返す。
つまりsiblingのcacheは自分のcacheのように使える。
http://www.flickr.com/photos/ediblexart/1557458575/ Siblings by EdiblexArt, on Flickr
二台hostがあったとして、それぞれのhostには自分のsiblingを書いてやりさえすればok
1.2.3.7の/etc/squid/sibling.confには
cache_peer 1.2.3.6 sibling 3128 3130
1.2.3.6の/etc/squid/sibling.confには
cache_peer 1.2.3.7 sibling 3128 3130
とでも書いて、include /etc/squid/sibling.conf してやればいい。
おまけ。
refresh_pattern . 0 100% 20160
としているが,20160は,最大cache時間が20160分(=14日)という意味.
結局のところ、/etc/squid/squid.conf
acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 443 # https
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow localhost
http_access deny all
icp_access allow localnet
icp_access deny all
http_port 3128
hierarchy_stoplist cgi-bin ?
access_log /var/log/squid/access.log squid
refresh_pattern . 0 100% 20160
coredump_dir /var/spool/squid
include /etc/squid/sibling.conf