【原】squid簡單應用

來源:互聯網
上載者:User
     squid的介紹大家可以從網上搜出一大堆的東東來。推薦一個不錯的文檔:
     http://home.arcor.de/mailerstar/jeff/squid/index.html
     squid的安裝按照上面的步驟去做就可以了。其實squid最重要的還是配置和理解概念。
     首先squid是非常重要的反向 Proxy的工具。關於反向 Proxy和正向 Proxy可以這樣理解:
     1.正向 Proxy:根正苗紅的代理。用戶端發來的請求,到了這個代理A處,它便直接將請求轉寄到B了。這要求用戶端合理配置。
     2.反向 Proxy:有點像動態include標籤。用戶端發來的請求,到了代理A處,它會向目標B發出請求,得到結果返回給用戶端。
     squid作為反響代理,一般理解兩個連接埠的概念就可以了。一個是監聽的連接埠,即http_port 預設是3128。還有一個就是代理的連接埠。比如8080.ftp的21連接埠等等。
     這些連接埠可以這樣理解:使用者發來請求到3128. squid會從代理的連接埠中找到比如8080.進行反向 Proxy。
    
     squid的簡單的命令應用:
     1 squid -k parse 建議修改完設定檔squid.conf。便運行下,進行校正。
     2.squid -z 初始化cache目錄。
     3.squid -d1 執行層級1.在前台運行
     4.squid -s 在後台執行。執行完用ps aux|grep squid可以看到兩個squid進程。
     5.squid -k reconfigure:修改完設定檔,可以這樣重讀。但是如果修改了cache目錄,則需要再執行squid -z後執行這個。
     6.squid -k restart kill shutdown  重啟。殺死進程。關閉請求命令。
 
     附錄:一個簡單的squid配置。在window下。
visible_hostname pony.asia
#Recommended minimum configuration:
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443
acl Safe_ports port 80        # http
acl Safe_ports port 8080    # tomcat
acl Safe_ports port 21        # ftp
acl Safe_ports port 443        # https
acl Safe_ports port 70        # gopher
acl Safe_ports port 210        # wais
acl Safe_ports port 1025-65535    # unregistered ports
acl Safe_ports port 280        # http-mgmt
acl Safe_ports port 488        # gss-http
acl Safe_ports port 591        # filemaker
acl Safe_ports port 777        # multiling http
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow all
icp_access allow all

#http_port 3128
http_port 80 accel vhost vport
cache_peer 127.0.0.1 parent 8080 0 no-query originserver

cache_mem 8 MB
maximum_object_size_in_memory 8 KB
memory_replacement_policy lru
cache_replacement_policy lru

cache_dir ufs c:/squid/cache 100 16 256

store_dir_select_algorithm least-load

max_open_disk_fds 0

minimum_object_size 0 KB

maximum_object_size 4096 KB

access_log c:/squid/logs/access.log squid

cache_log c:/squid/logs/cache.log

cache_store_log c:/squid/logs/store.log

mime_table c:/squid/etc/mime.conf

pid_filename c:/squid/logs/squid.pid

coredump_dir c:/squid/var/cache

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.