squid3配置手记

#
# Recommended minimum configuration:
#

visible_hostname main1.cdn.mydomain.com
cache_effective_user nobody
cache_effective_group nobody
cache_mgr tangj@mydomain.com

acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
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 localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
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

# mydomain ip
acl mydomain_company src 221.226.88.106 218.94.15.18
acl sites_ip src 96.44.179.110
acl sites_ip src 223.4.24.228

acl sites dstdomain .mydomain.com
acl sites dstdomain .mydomain.cn
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost all
http_access deny manager
reply_header_access Via deny all
reply_header_access Warning deny all

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
#http_access allow all Safe_ports
http_access allow sites
http_access deny all
# Squid normally listens to port 3128
http_port 80 vhost
#vhost

cache_mem 128 MB
cache_swap_low 85%
cache_swap_high 90%

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /disk-data/server_data/squid/var/cache 4096 16 256

# Leave coredumps in the first cache dir
coredump_dir /disk-data/server_data/squid/var/cache

cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=cn login=PASS
cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=www
cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=info
cache_peer 172.16.10.181 parent 8802 0 no-query originserver name=file
cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=123
cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=lad
cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=sso
cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=manager
cache_peer 172.16.10.181 parent 8801 0 no-query originserver name=sync.cc

# 如果在同一ip和端口上有不同的父级服务器,如:以上file和cn在的父级不一样,则用cache_peer_domain
cache_peer_domain cn cn.mydomain.com mydomain.com web1.host.mydomain.com mydomain.cn www.mydomain.cn
cache_peer_domain www www.mydomain.com en.mydomain.com
cache_peer_domain info info.mydomain.com
cache_peer_domain file file.mydomain.com
cache_peer_domain 123 123.mydomain.com
cache_peer_domain lad lad.mydomain.com
cache_peer_domain sso sso.mydomain.com
cache_peer_domain manager manager.mydomain.com
cache_peer_domain sync.cc sync.cc.mydomain.com

# 如果父级都一样,用cache_peer_access更方便
cache_peer_access cn allow sites
cache_peer_access www allow sites
cache_peer_access info allow sites
cache_peer_access file allow sites
cache_peer_access lad allow sites
cache_peer_access 123 allow sites
cache_peer_access sso allow sites
cache_peer_access manager allow sites
cache_peer_access sync.cc allow sites

# 指定访问ip,在设置子cache服务器访问权时很有用
cache_peer_access cn allow sites_ip
cache_peer_access www allow sites_ip
cache_peer_access info allow sites_ip
cache_peer_access file allow sites_ip
cache_peer_access lad allow sites_ip
cache_peer_access 123 allow sites_ip
cache_peer_access sso allow sites_ip
cache_peer_access manager allow sites_ip
cache_peer_access sync.cc allow sites_ip

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
#refresh_pattern . 0 20% 4320
refresh_pattern -i \.css$ 300 50% 60000
refresh_pattern -i \.xml$ 300 50% 60000
refresh_pattern -i \.html$ 600 90% 60000
refresh_pattern -i \.shtml$ 600 90% 60000
refresh_pattern -i \.jpg$ 300 90% 60000 ignore-reload
refresh_pattern -i \.png$ 300 90% 60000 ignore-reload
refresh_pattern -i \.gif$ 600 90% 60000 ignore-reload
refresh_pattern -i \.bmp$ 300 90% 60000 ignore-reload
refresh_pattern -i \.js$ 300 90% 60000

发表评论

电子邮件地址不会被公开。 必填项已用*标注