- 论坛徽章:
- 0
|
本文来自:
IT运维专家网(LinuxTone.Org)
作者:
ytjwt
原文链接:
http://bbs.linuxtone.org/thread-2369-1-1.html
IT运维专家网--"自由平等,互助分享!"
squid.conf
#
acl CactiServer src 192.168.0.119
acl snmpcommunity snmp_community public
snmp_port 3401
snmp_access allow snmpcommunity CactiServer
#这部分是为cacti的监控设置
#用snmpwalk -c public -v1 192.168.0.119:3401 .1.3.6.1.4.1.3495.1 测试是否成功
#
visible_hostname cache.lamiu.com
cache_effective_user squid
cache_effective_group squid # 启动的用户与组
cache_mgr
yangting@lamiu.com
cache_dir ufs /var/cache/squid/cache/ 1024 16 128 #缓存的路径,大小为1024M 16个头目录,128个子目录
cache_mem 128 MB #内存
cache_peer
www.lamiu.com
parent 80 0 no-query originserver name=www
cache_peer bbs.lamiu.com parent 80 0 no-query originserver name=bbs #定义不同的父节点,将节点设为no-query以及originserver说明这些节点是实际服务器
cache_peer_domain www
www.lamiu.com
cache_peer_domain bbs bbs.lamiu.com #设定不同域名转发到不同的cache_peer上,如果没有这项.不同域名的域名可能被分发到同一台服务器上.
acl all src 0.0.0.0/0.0.0.0
http_access allow all #允许所有客户端访问
cache_swap_high 100%
cache_swap_low 95% #(cache_swap_low 和cache_swap_high 指令控制了存储在磁盘上的对象的置换。它们的值是最大cache 体积的百分比,这个最大cache 体积来自于所有cache_dir 大小的总和)
maximum_object_size 1024 KB #大于此容量的对象将不会被保存在磁盘上,默认大小是4M,
maximum_object_size_in_memory 100 KB # 最大位于内存中的对象的大小,默认大小是8K,
hierarchy_stoplist cgi-bin ?
hierarchy_stoplist -i ^https:\\ ? #squid将请求标记为不可层叠,直接转发
emulate_httpd_log on #打开emulate_httpd_log选项,将使Squid仿照Aapche的日志格式
cache_store_log none #这个设置是不记录store.log
pid_filename /var/log/squid/squid.pid
cache_log /var/log/squid/cache.log
access_log /var/log/squid/access.log
half_closed_clients off #半关闭状态的TCP连接,设为off,则一旦从客户端返回“no more data to read”的信息,squid就立即关闭该连接
logfile_rotate 4 #可以用logfile_rotate 0来取消自动操作
acl QUERY urlpath_regex -i cgi-bin \? \.php \.xml
acl denyssl urlpath_regex -i ^https:\\
no_cache deny QUERY
no_cache deny denyssl #不对符合QUERY,denyssl的ACL内容进行缓冲
acl localhost src 127.0.0.1/255.255.255.255
acl manager proto cache_object
acl purge method PURGE
http_access allow manager localhost #cache_object是squid的缓存管理接口,这配置行只允许本机的缓存管理请求
http_access allow purge localhost #只有本机能删除了cache目标 squidclien -m PURGE -p 80 http://www.***.com
#refresh_pattern 指令间接的控制磁盘缓存。
#refresh_pattern [-i] regexp min percent max [options]
refresh_pattern -i \.jpg$ 30 50% 4320 reload-into-ims
refresh_pattern -i \.htm$ 0 20% 1440
#refresh_pattern 指令也有少数选项导致squid 违背HTTP 协议规范。它们如下:
override-expire
该选项导致squid在检查Expires 头部之前,先检查min 值。这样,一个非零的min 时间让squid返回一个未确认的cache 命中,即使该响应准备过期。
override-lastmod
改选项导致squid 在检查LM-factor 百分比之前先检查min 值。
reload-into-ims
该选项让squid 在确认请求里,以no-cache 指令传送一个请求。换句话说,squid在转发请求之前,对该请求增加一个If-Modified-Since头部。注意这点仅仅在目标有Last-Modified时间戳时才能工作。外面进来的请求保留no-cache 指令,以便它到达原始服务器。
ignore-reload
该选项导致squid 忽略请求里的任何no-cache 指令。
#squidclient -r -p 80 http://www.***.com 能Force cache to reload URL
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38871/showart_2084446.html |
|