acl all src all #定义IP访问列表 acl localhost src 127.0.0.1 /255 .255.255.255 #定义管理查看的地址段 acl manager proto cache_object #定义管理规则 cache_dir ufs /data/cache 2048 16 256 #指定缓存目录 20G,16个1级目录,256个二级目录。 cache_swap_high 95 #最多允许使用swap 95% cache_swap_low 90 #最小允许使用swap 90% acl SSL_ports port 443 #定义端口 acl Safe_ports port 80 #定义端口 acl Safe_ports port 443 #定义端口 acl CONNECT method CONNECT #请求方法以CONNECT,能动态切换到隧道的代理 acl allow_80 url_regex ^http: // .* #定义url的匹配规则 acl allow_443 url_regex ^https: // .* #定义url的匹配规则 acl managercache src 127.0.0.1 10.0.1.60 #定义PURGE模块管理地址 acl Purge method PURGE #定义开启PURGE模块 acl QUERY urlpath_regex \.js \.css \.ico \.gif \.jpg \.jpeg \.png \.html \.htm #定义缓存类型 http_access allow manager localhost #允许管理地址管理 http_access allow localhost manager #允许管理地址管理 http_access allow managercache Purge ##允许PURGE列表 http_access deny Purge #拒绝其他管理PURGE http_access deny !Safe_ports #拒绝除safe_ports以外端口 http_access deny CONNECT !SSL_ports #拒绝除SSL_ports以外使用connect方式。 http_access allow all #允许任何人访问 http_port 80 accel vhost vport #监听80 ###accel 为加速模式 squid2.6以上版本加速模式配置方法。 cache_peer xx.xx.xx.11 parent 80 0 originserver no-query name=web1_80 ##定义代理IP 及端口 #NO-QUERY:不做查询操作,直接获取数据 #originserver 参数指明是源服务器,round-robin 参数指明 squid 通过轮询方式将请求分发到其中一台父节点 cache_peer xx.xx.xx.12 parent 80 0 originserver no-query name=web2_80 cache_peer_access web1_80 allow allow_80 ##定义http开头的url访问name为web1、web2(根据上面定义的url_regex规则) cache_peer_access web2_80 allow allow_80 ##定义http开头的url访问name为web1、web2(根据上面定义的url_regex规则) https_port 443 cert= /usr/local/squid/etc/xxxxxx .crt key= /usr/local/squid/etc/xxxxxx .key accel vhost vport cache_peer xx.xx.xx.11 parent 443 0 no-query originserver round-robin ssl sslflags=DONT_VERIFY_PEER name=web1_443 ##ssl为指定协议,sslflags=DONT_VERIFY_PEER 为不进行源端SSL证书验证,可以解决上级网站采用自签证书造成的中断,以及减少响应时间 cache_peer xx.xx.xx.12 parent 443 0 no-query originserver round-robin ssl sslflags=DONT_VERIFY_PEER name=web2_443 cache_peer_access web1_443 allow allow_443 ##定义https开头的url访问name为web1、web2(根据上面定义的url_regex规则) cache_peer_access web2_443 allow allow_443 ##定义https开头的url访问name为web1、web2(根据上面定义的url_regex规则) #emulate_httpd_log on ##开启apache默认的log格式,不过3.1中不认次参数,去掉一样生效 logfile_rotate 24 ##定义access.log轮训数到24, access.log0 access.log1 ....access.log24 access_log /data/squid_log/access .log squid #定义路径 cache deny !QUERY #拒绝除定义的缓存类型以外的其他类型的缓存 refresh_pattern -i www\.xxxxxx\.com 240 90% 1440 ignore-reload #ignore-reload让squid忽略所有请求里的reload refresh_pattern -i qiye\.xxxxxxx\.com 240 90% 1440 ignore-reload refresh_pattern . 120 50% 1440 # #配置Squid的刷新策略 . 所有类型 最小时间 刷新节点百分比 最大时间 acl apache rep_header Server ^Apache #允许apache的编码 visible_hostname cdn-xx.xxx.com # 机器名称 cache_mgr [email protected] #管理员邮箱 |