• Windows Squid 安装配置


    squid 可以做反向代理将系统中相对静态的页面进行缓存和负责均衡,
    提高网站访问速度,增强网站可用性、安全性.
    用户访问Squid 反向代理服务器的 IP 地址,这样客户端的 URL 请求将被发送到反向代理服务器。
    如果Squid反向代理服务器中缓存了该请求的资源,则将该请求的资源直接返回给客户端,
    否则反向代理服务器将向后台的 WEB服务器请求资源,然后将请求的应答返回给客户端,
    同时也将该应答缓存在本地,供下一个请求者使用。

    其示意图如下:

    Windows中安装squid步骤:
    1,从http://squid.acmeconsulting.it下载squid windows的安装文件.
    也可以从http://download.csdn.net/detail/kkdelta/4474605下载.
    下载后解压将squid放在C:目录下(default),你也可以把Squid放到其他的路径,
    但是需要大量的配置squid配置文件中的路径信息。
    2,重命名etc文件夹下的文件
    squid.conf.default ==> squid.conf
    mime.conf.default ==> mime.conf
    cachemgr.conf.default ==> cachemgr.conf 
    3,简单配置squid.conf,使配置达到如下图的效果

    visible_hostname squidhost
    #设定squid的主机名,如无此项squid将无法启动
    http_port 3128 accel vhost vport
    #设定squid为accel加速模式,vhost必须要加.否则将无法将主机头转发至后端服务器,
    #访问时就会出现无法找到主机头的错误
    cache_peer 147.151.240.234 parent 8080 0 no-query originserver round-robin name=webserver1
    cache_peer 147.151.241.151 parent 8080 0 no-query originserver round-robin name=webserver2
    cache_peer_domain  webserver1 webserver2 localhost
    #将 localhost的请求通过 RR 轮询方式转发到2个父节点中的一个.
    #http://localhost:3128的请求将转发到147.151.240.234:8080或者147.151.241.151:8080
    acl all src 0.0.0.0/0.0.0.0
    http_access allow all

    4,启动squid
    C:squidsbin>squid -z #创建cache目录.
    C:squidsbin>squid #启动squid

    测试:
    将147.151.240.234和147.151.241.151的tomcat启动,放上一个test.jsp文件.
    在151的机器上的test.jsp输出 The JSP in Tomcat instance 151 
    在234的机器上的test.jsp输出 The JSP in Tomcat instance 234
    访问http://localhost:3128/xxxweb/test.jsp会轮流输出上面的结果.
    对一个jsp的访问每次都会转发到web server上:X-Cache: MISS from squidhost


     
    1. [root@Fedora-WLS9-1 bin]# curl -I http://147.151.240.52:3128/examples/jsp/test.jsp  
    2. HTTP/1.0 200 OK  
    3. Server: Apache-Coyote/1.1  
    4. Set-Cookie: JSESSIONID=F3C10D53A916B1852D06687E9E581A2F; Path=/examples  
    5. Content-Type: text/html  
    6. Content-Length: 972  
    7. Date: Fri, 03 Aug 2012 17:51:01 GMT  
    8. X-Cache: MISS from squidhost  
    9. X-Cache-Lookup: MISS from squidhost:3128  
    10. Via: 1.0 squidhost:3128 (squid/2.6.STABLE22)  
    11. Connection: close  

    对一个静态的html的访问每次都会转发到web server上:X-Cache: HIT from squidhost


     
      1. [root@Fedora-WLS9-1 bin]# curl -I http://147.151.240.52:3128/examples/jsp/test.html  
      2. HTTP/1.0 200 OK  
      3. Server: Apache-Coyote/1.1  
      4. Accept-Ranges: bytes  
      5. ETag: W/"26-1343982480000"  
      6. Last-Modified: Fri, 03 Aug 2012 08:28:00 GMT  
      7. Content-Type: text/html  
      8. Content-Length: 26  
      9. Date: Fri, 03 Aug 2012 17:28:54 GMT  
      10. Age: 195  
      11. <span style="color:#FF0000;"></span>X-Cache: HIT from squidhost  
      12. X-Cache-Lookup: HIT from squidhost:3128  
      13. Via: 1.0 squidhost:3128 (squid/2.6.STABLE22)  
      14. Connection: close  
  • 相关阅读:
    bash 中 () {} [] [[]] (()) 的解释
    正则表达式速查笔记
    Makefile速查笔记
    gflags 编译动态库
    在Win10上运行ESXI-Comstomer
    GNU g++常用编译选项用法
    C++标准转换运算符reinterpret_cast
    BZOJ 3211: 花神游历各国【线段树区间开方问题】
    BZOJ 1597: [Usaco2008 Mar]土地购买【斜率优化+凸包维护】
    BZOJ 1046: [HAOI2007]上升序列【贪心+二分状态+dp+递归】
  • 原文地址:https://www.cnblogs.com/fklin/p/5820160.html
Copyright © 2020-2023  润新知