#
visible_hostname sendmail.cxkj.com
dns_nameservers 192.168.1.10
cache_mgr root@sendmail.cxkj.com
cache_effective_user squid
cache_effective_group squid
# Recommended minimum configuration:
#
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.1.0/24 # 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
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access allow manager
# Deny requests to certain unsafe ports
#http_access allow all
# Deny CONNECT to other than secure SSL ports
#http_access allow 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
# Squid normally listens to port 3128
#http_port 80 accel vhost vport
http_port 80 accel vhost vport
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /usr/local/squid/var/cache 10000 16 256
# Leave coredumps in the first cache dir
coredump_dir /usr/local/squid/var/cache
# 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
cache_log /usr/local/squid/var/logs/cache.log
access_log /usr/local/squid/var/logs/access.log squid
cache_store_log /usr/local/squid/var/logs/store.log
pid_filename /usr/local/squid/var/logs/squid.pid
cache_mem 1024 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 512000 KB
minimum_object_size 4096 KB
#cache_peer 192.168.1.10 parent 80 0 no-query originserver round-robin
#cache_peer 192.168.1.243 parent 80 0 originserver
#cache_peer html.cxkj.com parent 80 0 originserver
#cache_peer html.cxkj.com parent 80 0 no-query round-robin originserver
#cache_peer_domain html.cxkj.com sendmail.cxkj.com
cache_peer 192.168.1.10 parent 80 0 no-query round-robin originserver
#cache_peer 192.168.1.10 parent 80 0 no-query round-robin originserver
cache_peer_domain 192.168.1.10 html.cxkj.com test.cxkj.com
#cache_peer_domain 192.168.1.10 test.cxkj.com
cache_peer_access 192.168.1.10 allow all
#cache_peer_access 192.168.1.10 allow all
保存退出。
最后修改/etc/hosts文件。
把squid添加到系统启动项
编辑 /etc/rc.d/rc.local
添加如下行: /usr/local/squid/sbin/squid -s
利用Runc脚本……..
ulimit -HSn 65535
ulimit -n
vim /etc/rc.d/rc.local
ulimit -HSn 65535
保存退出。
7、相关配置
初始化目录
#/usr/local/squid/sbin/squid -z
检查语法:
#/usr/local/squid/sbin/squid -k parse
开启服务:
#/usr/local/squid/sbin/squid –NCd1 (前台正式运行,用于调试非常好.)
#/usr/local/squid/sbin/squid (后台运行)
更新配置文件:
# /usr/local/squid/sbin/squid -k reconfig (更新配置文件后更新)
关闭squid
/usr/local/squid/sbin/squid -k interrupt
滚动日志文件
/usr/local/squid3/sbin/squid -k rotate
检测系统运行状态
/usr/local/squid/bin/squidclient -h 192.168.1.202 -p 80 mgr:info
清空缓存:
/usr/local/squid/bin/squidclient -h 192.168.1.202 -p 80 -m
8、配置完成:
最后检测:
用Linux自带的工具检测一下Http头看Cache生效没
#curl -I
如信息中出现有以下这一行就代表缓存生效了。
X-Cache: HIT from squid
如果是
X-Cache: MISS from squid
就代表缓存还没储存,或者是没生效.
3,查看你的日志文档。
#more /usr/local/squid/var/logs/access.log | grep TCP_MEM_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到内存中,并返回给访问用户。
#more /usr/local/squid/var/logs/access.log | grep TCP_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到cache目录中,并返回给访问用户。
#more /usr/local/squid/var/logs/access.log | grep TCP_MISS
该指令可以看到在squid运行过程中,有那些文件没有被squid缓存,而是现重原始服务器获取并返回给访问用户。
关于 TCP_XXXX 等参数及代表的信息,请参看《squid中文权威指南》13.2.1 章节。