squid.conf典型配置范例

来源:互联网 发布:黑色沙漠巫师捏脸数据 编辑:程序博客网 时间:2024/05/01 17:31

# visible name
visible_hostname proxy
# cache config: space use 1G and memory use 256M
cache_dir ufs /usr/local/squid/cache 10240 256 256
cache_swap_low 90
cache_swap_high 95
maximum_object_size 20000 KB
maximum_object_size_in_memory 8192 KB
minimum_object_size 0 KB
ipcache_size 16384
ipcache_low 80
ipcache_high 90

cache_mem 512 MB
cache_mgr webmaster@domain.com
cache_effective_user squid
cache_effective_group squid

#refresh
refresh_pattern -i .gif$ 3600 80% 36000 reload-into-ims
refresh_pattern -i .jpg$ 3600 80% 36000 reload-into-ims
refresh_pattern -i .png$ 3600 80% 36000 reload-into-ims

refresh_pattern -i .exe$ 3600 80% 36000 ignore-reload
refresh_pattern -i .torrent$ 3600 80% 36000 reload-into-ims
refresh_pattern -i .html$ 60 80% 600 reload-into-ims
refresh_pattern -i .htm$ 1800 80% 3600 reload-into-ims
refresh_pattern -i .swf$ 3600 80% 18000 reload-into-ims

#refresh_pattern -i .php$ 3600 80% 18000 reload-into-ims

refresh_pattern -i .mp3$ 3600 80% 36000 reload-into-ims
refresh_pattern -i .wmv$ 3600 80% 36000 reload-into-ims
refresh_pattern -i .rm$ 3600 80% 36000 reload-into-ims
refresh_pattern -i .mpeg$ 3600 80% 36000 reload-into-ims
refresh_pattern -i .wma$ 3600 80% 36000 reload-into-ims

refresh_pattern -i .css$ 1800 80% 3600 reload-into-ims
refresh_pattern -i .js$ 1800 80% 3600 reload-into-ims
refresh_pattern -i .xml$ 1800 80% 3600 reload-into-ims

range_offset_limit 0 KB

#squid ip:port

http_port 192.168.1.1:80 vhost vport

# Timeouts
# forward_timeout 4 minutes

forward_timeout 20 seconds
# connect_timeout 1 minute

connect_timeout 60 seconds
# read_timeout 15 minutes
read_timeout 5 minutes

# request_timeout 5 minutes
request_timeout 3 minutes

# persistent_request_timeout 1 minute
persistent_request_timeout 30 seconds

# client_lifetime 1 day
client_lifetime 15 minutes

# pconn_timeout 120 seconds
# shutdown_lifetime 30 seconds
shutdown_lifetime 15 seconds

half_closed_clients off
server_persistent_connections on
client_persistent_connections on
forwarded_for on

# access arc
acl all src 0.0.0.0/0.0.0.0
# Allow requests when they are to the accelerated machine AND to the
# right port with right protocol
emulate_httpd_log on
cache_store_log /home/squid-log/store/store.log
cache_log /home/squid-log/cache/cache.log
cache_access_log /home/squid-log/access/access.log
# logfile_rotate 10
logfile_rotate 3

acl conncount maxconn 38400

#webserver IP
acl myip dst 192.168.1.2,192.168.1.3
http_access deny !myip

acl Manager proto cache_object
#squid IP
acl Localhost src 127.0.0.1 192.168.1.1
http_access allow Manager Localhost
http_access deny Manager

acl PURGE method PURGE
#acl localhost src 127.0.0.1
http_access allow PURGE localhost
http_access deny PURGE

acl Safe_ports port 80 81
http_access deny !Safe_ports
http_access allow all

#webserver IP、domain
cache_peer 192.168.1.2 parent 80 0 no-query originserver name=example.www
cache_peer_domain example.www www.example.com
cache_peer 192.168.1.3 parent 80 0 no-query originserver name=example
cache_peer_domain example example.com