squid3.0都出了,我今刚把2.6配置成功,看完了<squid权威指南>.权威指南的后几章只是草草看了,似乎和实际应用挂钩不多,都是太复杂的需求了,一般也就用到的是普通页面加速。
在配置过程中遇到SQUID一直提示无法取到原数据,我是在一台独立服务器上装了APACHE和SQUID,后来经过多次调试,增加了cache_peer的设置就好了,还没琢磨明白,为什么要设置cache_peer,难道默认他是打开的?配置文件估计还不是最简的,可能还可以去掉些多于配置。
http_port 8080(squid使用8080端口) defaultsite=www.xxx.com.cn(源主机host)
cache_peer 202.106.184.252 parent 80 0 no-query originserver
cache_mem 64 MB
cache_log /data1/squid/var/cache.log
cache_dir ufs /data1/squid/var/cache 10240 64 64(cache大小 及目录结构 2层64*64)
cache_access_log /data1/squid/var/logs/access.log
#cache_access_log none
cache_log /data1/squid/var/logs/squid.log
#cache_store_log none
cache_store_log /data1/squid/var/logs/store.log
hosts_file /usr/local/squid/etc/hosts.squid (源主机host ip文件)
acl all src 0.0.0.0/0.0.0.0
acl Safe_ports port 8080 # http
acl Safe_ports port 80
acl CONNECT method CONNECT
acl allowed_ports port 80
acl allowed_ports port 8080
acl allowed_doms dstdomain .xxx.com.cn
acl allowed_methods method GET
acl allowed_methods method POST
acl allowed_methods method HEAD
http_access allow all
http_reply_access allow all
补充一个别人的,带防盗链的
#squid.conf
#服务器IP 192.168.1.1
#监听服务器的80端口,透明代理,支持域名和IP的虚拟主机
http_port 192.168.1.1:80 transparent vhost vport
#限制同一IP客户端的最大连接数
acl OverConnLimit maxconn 16
http_access deny OverConnLimit
#防止天涯盗链,转嫁给百度
acl tianya referer_regex -i tianya
http_access deny tianya
deny_info http://www.baidu.com/logs.gif tianya
#防止被人利用为HTTP代理,设置允许访问的IP地址
acl myip dst 192.168.1.1
http_access deny !myip
#防止百度机器人爬死服务器
acl AntiBaidu req_header User-Agent Baiduspider
http_access deny AntiBaidu
#允许本地管理
acl Manager proto cache_object
acl Localhost src 127.0.0.1 192.168.1.1
http_access allow Manager Localhost
http_access deny Manager
#仅仅允许80端口的代理
acl Safe_ports port 80 # http
http_access deny !Safe_ports
http_access allow all
#Squid信息设置
visible_hostname www.test137.com
cache_mgr webmaster@test137.com
#基本设置
cache_effective_user squid
cache_effective_group squid
tcp_recv_bufsize 65535 bytes
#2.5的反向代理加速配置
#httpd_accel_host 127.0.0.1
#httpd_accel_port 80
#httpd_accel_single_host on
#httpd_accel_uses_host_header on
#httpd_accel_with_proxy on
#2.6的反向代理加速配置
#代理到本机的80端口的服务,仅仅做为原始内容服务器
cache_peer 127.0.0.1 parent 80 0 no-query originserver
#错误文档
error_directory /usr/local/squid/share/errors/Simplify_Chinese
#单台使用,不使用该功能
icp_port 0