squid配置

来源:互联网 发布:linux下tty级别 编辑:程序博客网 时间:2024/05/21 17:51

#http_port 80 accel defaultsite=www.test.com protocol=http
#http_port 80 vhost
http_port 80 accel vhost vport

acl acceleratedProtocol protocol HTTP
acl acceleratedPort port 8880

acl OverConnLimit maxconn 255
http_access deny OverConnLimit

icp_port 0
tcp_recv_bufsize 65535 bytes

cache_replacement_policy lru
memory_replacement_policy lru

cache_mem 512 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 4096 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 128 KB
cache_dir ufs /var/cache/squid 2048 16 256

ipcache_size 1024
ipcache_low 90
ipcache_high 95

forward_timeout 20 seconds
connect_timeout 15 seconds
read_timeout 3 minutes
request_timeout 1 minutes
persistent_request_timeout 15 seconds
client_lifetime 15 minutes
shutdown_lifetime 5 seconds
negative_ttl 10 seconds

emulate_httpd_log on
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h"
redirect_rewrites_host_header off
log_ip_on_direct on
#pid_filename /opt/web-squid/var/logs/squid.pid

logfile_rotate 5

access_log /var/log/squid/access.log combined
cache_access_log /var/log/squid/cache_access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
cache_swap_log /var/log/squid/swap.log

visible_hostname cache.localhost
cache_mgr webmaster@cache.localhost

acl all src 0.0.0.0/0.0.0.0
http_access allow all

cache_peer 192.168.1.221 parent 80 0 no-query originserver weight=1 name=myhost
cache_peer 192.168.1.221 parent 8080 0 no-query originserver weight=1 name=myhost1
cache_peer www.tsts168.com parent 80 0 no-query originserver weight=1 name=tsts168
cache_peer forum.tsts168.com parent 80 0 no-query originserver weight=1 name=forum

cache_peer_domain myhost www.test.com
cache_peer_domain myhost1 www.test1.com
cache_peer_domain tsts168 tsts168.com www.tsts168.com
cache_peer_domain forum forum.tsts168.com blog.tsts168.com

cache_peer_access myhost allow all
cache_peer_access myhost1 allow all
cache_peer_access tsts168 allow all
cache_peer_access forum allow all

acl manager proto cache_object
acl inside src 192.168.1.0/24
http_access allow manager
http_access deny manager !inside
cachemgr_passwd 123456 all


#Recommended minimum configuration:origin config.
#acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
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

#http_access allow manager localhost
#http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
icp_access allow all

#hierarchy_stoplist cgi-bin ?
#acl QUERY urlpath_regex cgi-bin /?
#cache deny QUERY

refresh_pattern ^ftp:        1440    20%    10080
refresh_pattern ^gopher:    1440    0%    1440
refresh_pattern -i /.xml    60    20%    440    ignore-reload
refresh_pattern -i /.jpg        3    50%     8    ignore-reload
refresh_pattern -i /.css        3    50%     8    ignore-reload
refresh_pattern -i /.js         3    50%     8    ignore-reload
refresh_pattern -i /.gif        3    50%     8    ignore-reload
refresh_pattern -i /.png        3    50%     8    ignore-reload
refresh_pattern -i /.htm        3    50%     8    ignore-reload
refresh_pattern -i /.exe        60    20%     440    ignore-reload
refresh_pattern -i /.mp3        60    20%     440    ignore-reload
refresh_pattern -i /.php        3      20%     440     ignore-reload
#refresh_pattern .               3      50%     8