26 Jan 2015
vi /etc/squid/squid.conf ================================================= ## 注释掉这一句 #http_port 3128 ## 在推荐的自定义区域增加如下内容: # 设定监听端口,并开启accelerator模式 http_port 80 accel vhost vport # accel:Accelerator / reverse proxy mode,accel后必须跟着vhost,vport和defalutsite中的一个或多个 # vhost:加速器模式使用Host header来支持虚拟主机,也会使用Host: header中指定的port,但是如果有vport,会被vport覆盖 # vport:虚拟主机端口支持,使用http_port配置取代Host: headers中指定的port # defaultsite=domainname:若request中未指定,为Host: header设定一个默认domain ## 源服务器配置 # [cache_peer][hostname][type][http_port][icp-port][options] cache_peer 45.114.10.220 parent 80 0 originserver name=example cache_peer_domain example linux.example.com #type:parent,sibling or multicast #name=a,cache_peer的别名 ## 访问控制 acl our_sites dstdomain linux.example.com http_access allow our_sites cache_peer_access example allow our_sites cache_peer_access example deny all ================================================= squid -k check squid -k rec curl -xlocalhost:80 linux.example.com -I HTTP/1.0 302 Moved Temporarily Server: nginx/1.8.0 Date: Thu, 22 Dec 2016 02:08:49 GMT Content-Type: text/html; charset=utf-8 Content-Length: 217 Location: http://linux.example.com/home X-Cache: MISS from node04 X-Cache-Lookup: MISS from node04:80 Via: 1.0 node04 (squid/3.1.23) Connection: keep-alive