Goodspeed

导航

squid 2.6缓存多个虚拟机配置及常用命令

安装笔记中的大多配置是默认的,作为测试用,如果要用到生产环境中还需更详细的配置,然后根据服务器运行状况不断调整,一般服务器可能会有多个虚拟主机,通过配置squid可以轻松为同一服务器上的多个虚拟主机进行缓存
cache_peer www.example.org.cn parent 80 0 no-query originserver
cache_peer www.example.net.cn parent 80 0 no-query originserver
acl exampleorg dstdomain .example.org.cn
acl examplenet dstdomain .example.net.cn

##1th
cache_peer_domain www.example.org.cn .example.org.cn
cache_peer_domain www.example.net.cn .example.net.cn
http_access allow exampleorg
http_access allow examplenet
http_access deny all
##2nd
cache_peer_access www.example.org.cn allow exampleorg
cache_peer_access www.example.net.cn allow examplenet
cache_peer_access www.example.org.cn deny all
cache_peer_access www.example.net.cn deny all
以上两种方式都可以达到为同一服务器上的多个虚拟主机进行缓存的目的,2.6改进之后配置相当灵活,包括Log配置、缓存规则配置、支持虚拟主机配置

另外需要注意一点的是经过apache的deflate模块压缩的文件可能不会被缓存,只要配置一下就可以
cache_vary on

squid常用命令
/usr/local/squid/sbin/squid -z 初始化缓存空间
/usr/local/squid/sbin/squid 启动
/usr/local/squid/sbin/squid -k shutdown 停止
/usr/local/squid/sbin/squid -k reconfigure 重新载入配置文件
/usr/local/squid/sbin/squid -k rotate 轮循日志

posted on 2008-11-12 11:32  Goodspeed  阅读(1020)  评论(0编辑  收藏  举报