rss· 投稿· 设为首页· 加入收藏· 繁體版

Squid配置

#服务器IP 192.168.1.103
#监听服务器的80端口,透明代理,支持域名和IP的虚拟主机
http_port 192.168.1.103:80  vhost#单台使用,不使用该功能
icp_port 0
#限制同一IP客户端的最大连接数
acl OverConnLimit maxconn 16
http_access deny OverConnLimit
#防止被人利用为HTTP代理,设置允许访问的IP地址
acl myip dst 192.168.1.103
http_access deny !myip
#防止百度机器人爬死服务器
acl AntiBaidu req_header User-Agent Baiduspider
http_access deny AntiBaidu
#允许本地管理
acl Manager proto cache_object
acl Localhost src  192.168.1.103
http_access allow Manager Localhost
http_access deny Manager
#仅仅允许80端口的代理
acl Safe_ports port 80 # http
http_access deny !Safe_ports
acl all src 0.0.0.0/0.0.0.0
http_access allow all
#Squid信息设置
visible_hostname 192.168.1.103
cache_mgr webmaster@admin.com
#基本设置
cache_effective_user squid
cache_effective_group squid
tcp_recv_bufsize 65535 bytes
#2.6的反向代理加速配置
#代理到本机的81端口的服务,仅仅做为原始内容服务器
cache_peer 192.168.1.103 parent 81 0 no-query originserver
#设置Squid所能使用的内存共64MB,这个值因人而异
cache_mem 64 MB
cache_swap_low 90
cache_swap_high 95
#最大缓存文件大小,超过这个值则不缓存,这个值因人而异
maximum_object_size 32768 KB
memory_pools_limit 100 MB
#装入内存缓存的文件大小
maximum_object_size_in_memory 256 KB
#磁盘缓存的类型和目录,大小,一二级目录的设置
#cache_dir aufs /var/log/squid/cache 5512 64 256
#设置不想缓存的目录或者文件类型
acl QUERY urlpath_regex cgi-bin .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe \?
cache deny QUERY
#打开emulate_httpd_log选项,将使Squid仿照Aapche的日志格式
emulate_httpd_log on
#日志格式combined的设置
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %{Host}>h %Ss:%Sh
#错误文档
#error_directory /var/log/squid/error
#这里是设置pid和日志文件的位置,因人而异,同时日志格式是combined
#pid_filename /var/log/squid/squid.pid
cache_log /var/log/squid/cache.log
access_log /var/log/squid/access.log combinedlogfile_rotate 4
cache_store_log nonehosts_file /etc/hosts
log_mime_hdrs off
strip_query_terms off
never_direct allow all
http_reply_access allow all
reload_into_ims on
redirect_rewrites_host_header off##time out control
#connect_timeout 2 seconds
peer_connect_timeout 2 seconds
#read_timeout    2 seconds
#request_timeout 2 seconds
#persistent_request_timeout 10 seconds
client_lifetime 100 minutes
#half_closed_clients on
#pconn_timeout   10 seconds
collapsed_forwarding on
refresh_pattern -i .html 0 40% 60 ignore-reload
refresh_pattern -i .hml 0 40% 60 ignore-reload
refresh_pattern -i .gif 10 40% 60 ignore-reload
refresh_pattern -i .swf 10 40% 60 ignore-reload
refresh_pattern -i .jpg  10 40% 60 ignore-reload
refresh_pattern -i .js$ 10 40% 60 ignore-reload
refresh_pattern -i .css  10 40% 60 ignore-reload
顶一下
(0)
踩一下
(0)