linux下安裝Squid代理的詳細配置教程

來源:互聯網
上載者:User

1.如果系統中還沒有裝squid,按以下順序輸入命令後即可完成安裝
# wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE18.tar.gz //下載Squid代理安裝包
# tar -zxvf squid-3.0.STABLE18.tar.gz //解壓Squid安裝包
# cd squid-3.0.STABLE18
# ./configure --prefix=/usr/local/squid --sysconfdir=/usr/local/squid/etc --bindir=/usr/local/squid/bin --sbindir=/usr/local/squid/sbin --mandir=/usr/local/squid/share/man --enable-gnuregex --enable-carp --enable-async-io=80 --enable-removal-policies=heap,lru --enable-icmp --enable-delay-pools --enable-useragent-log --enable-referer-log --enable-kill-parent-hack --enable-snmp --enable-arp-acl --enable-htcp --enable-cache-digests --enable-default-err-language=Simplify_Chinese --enable-err-languages="Simplify_Chinese" --enable-poll --enable-linux-netfilter --disable-ident-lookups --enable-underscores --enable-auth="basic" --enable-basic-auth-helpers="NCSA" --enable-external-acl-helpers="ip_user" --enable-x-accelerator-vary //配置Squid代理安裝路徑之類的
# make //編譯
# make install //安裝Squid代理軟體

----------------------------------

2.安裝好後設定檔在/usr/local/squid/etc目錄中,刪除原有的squid.conf設定檔,建立squid.conf檔案,只輸入以下內容:
http_port 80 transparent
http_access allow all

注意,以上是squid2.6及以後版本的配置,如果是2.6以前版本的squid,配置如下:
http_port 80
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

----------------------------------

3./usr/local/squid/sbin目錄下的squid為運行檔案。
第一次運行時,先運行squid -z建立快取檔案夾。快取檔案夾在/usr/local/squid/var下建立,因此建立緩衝前還需運行chmod 777 /usr/local/squid/var給該檔案夾許可權。
再運行squid -d 1開啟squid即可。
如果要關閉squid,運行squid -k shutdown則是安全關閉。
注意,如果沒有將新裝的squid配置成環境變數的話,盡量在sbin目錄下運行./squid,以免運行了伺服器上已有的舊squid。

----------------------------------

4.設定一個DNS伺服器,將所有網域名稱解析指向到需要被代理的伺服器的IP,例如使用Bind,WinMyDns軟體。將squid所在伺服器的DNS設定成該DNS伺服器。

5.將被代理的伺服器所有網域名稱解析到squid所在伺服器,這時該伺服器即可作為中轉。

----------------------------------

可能的問題:
Squid有時候運行時會有報錯:
clientNatLookup: NF getsockopt(SO_ORIGINAL_DST) failed: (92) Protocol not available
不過似乎不影響訪問

相關文章

聯繫我們

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