Windows Squid 安裝配置

來源:互聯網
上載者:User

標籤:

squid 可以做反向 Proxy將系統中相對靜態頁面進行緩衝和負責均衡,
提高網站訪問速度,增強網站可用性、安全性.
使用者訪問Squid 反向 Proxy伺服器的 IP 位址,這樣用戶端的 URL 請求將被發送到反向 Proxy伺服器。
如果Squid反向 Proxy伺服器中緩衝了該請求的資源,則將該請求的資源直接返回給用戶端,
否則反向 Proxy伺服器將向背景 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:\squid\sbin>squid -z #建立cache目錄.
C:\squid\sbin>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. [[email protected]dora-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. [[email protected] 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  

Windows Squid 安裝配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.