2.1 主要架構介紹
internet
internet
2.2 Squid 的安裝
Squid 是一套相當知名的 Proxy Caching Server(快取代理者伺服 器),專門用來加快讀取 http、ftp、gopher 等協定所傳出的資料。
當安裝 Redhat+Cle 的 Server 套件後,系統並不包含 Squid Proxy Server,除非使用 Custom 套件事先安裝或是事後自行安裝。安裝 Squid 程序相當簡單,程序如下:
1.#mount/mnt/cdrom。
2.#cd/mnt/cdrom/Redhet/RPMS/。
3.#rpm-Uvh squid-*。
在此所安裝的是 Squid-2.3.STABLE*版本,安裝好 Squid 後,Squid 尚未啟動,即使從新開機也不會啟動,需要使用 linuxconf 設定 Linux 一開機後就自動啟動 Squid,由以下步驟設定:
1. #setup。(啟動 setup)
2. 按一下「System services」項目。
3. 設定「squid」項目為 Enable。
4. 按一下「OK」、「Quit」。
P.S. 可到以下網站下載最新的 RPM 版本 Client
Proxy server
Web Server
http://www.acore.com.tw/~gau/works/rpms 若 Squid 想採用傳統的安裝方式,到 squid 官方網站 http://squid.nlanr.net 下載最新版的 Squid proxy。
接著設定如下:
1. #adduser-M squid
:建立一新無個人空間的帳號 squid,並且隸屬於 squid 群組。
2. su squid
:從 root 身分 su 成 squid。
3. % tar xzf squid-2.3.RELEASE-src.tar.gz 4. % cd squid-2.3.RELEASE
5. % ./configure
:內定安裝 squid 的目錄為/usr/local/squid。
6. % make
7. % make install
8. % cd/usr/local/squid/bin 9. /usr/local/squid/bin/squid-z :製作快取目錄。
10. ./RunCache
:執行 squid daemon
注意一: 若不清楚 configure 參數,可以執行% ./configure--help,
已獲悉完整的 configure 參數。
注意二:Squid Proxy 內設傳輸資料的 Port 是 3128,當您在瀏覽器
(如 IE、Netscape)裡使用 Proxy 選項時,請記得將 Proxy Server 的 Port 設定為:3128
2.3 Squid 的組織結構介紹
在真正規劃 Squid cache 與設定 Squid 組態檔之前,簡單的介紹 rpm 型態的 Squid 內定的目錄與檔案組織結構,以利於設定 Squid 組態檔 (/etc/squid.conf)。
squid 的檔案大致分為三類:組態檔、應用程式檔及各項紀錄檔(logs files)。對其他伺服器而言,或許紀錄檔不是挺重要的一部分,但是 對於 Squid 而言,紀錄檔族是相當的重要喔!
【Squid 的組態檔及結構】
rpm 格式的 squid,內定放置相關組態檔案的目錄是/etc/squid,其 完整結構如下所示:
/etc/squid
|
--errorÆ /usr/lib/squid/errors/English ;錯誤時所用的語系|
--mib.txt ;SQUID-MIB 定義檔|
--mime.conf ;定義 Squid 所任式的 mine type|
--mime.conf.default ;Squid 內定 mine type 檔|
--squid.conf ;目前使用的 squid 組態檔|
--squid.conf.default ;Squid 內定組態檔【Squid 傳統安裝的組織結構】
本系統使用傳統 Compiler 方式安裝 squid,其內定的目錄安裝在 /usr/local/squid 目錄下,因此所有與 Squid 相關的檔案都在此目錄 下,其結構如下:
/usr/local/squid
|
-- bin ;放置 squid 相關執行檔|
|
--RunAccel|
|
--RunCache ;執行 squid 的 Script|
|
--cachemgr.cgi ;查看 squid 即時運作的程式|
|
--client ;統計並顯示 digest table 的內容|
|
--dnsserver ;輔助 squid 處理領域名稱解析|
|
--squid ; squid daemon,主程式|
、--unlinkd|
-- etc ;放置 squid 相關組態檔|
|
--errors|
|
--icons|
|
--mib.txt ;SQUID-MIB 定義檔|
|
--mime.conf ;定義 squid 所任式的 mine type|
|
--mime.conf.default ; squid 內定的 mine type 檔|
|
--squid.conf ;目前使用的 squid 組態檔|
、--squid.conf.default ; squid 內定組態檔、--logs ;放置 logs 目錄
|
--access.log ;client 端使用 Proxy 的紀錄檔|
--store.log ;儲存快取物件的狀態紀錄檔、--cache.log ;cache 的啟動及各類狀態紀錄檔 此類架構由於將所有與 squid 相關的檔案,程式放置在
/usr/local/squid 目錄下,所以管理上顯得相當的容易。
2.4 squid.conf 的設定
設定檔位置:/usr/local/squid/etc/squid.conf 修改下列各項設 定。
修改參數 注意事項 http_port 3128 將 # 註解拿掉
icp_port 3130 將 # 註解拿掉
cache_mem 8MB 將 # 註解拿掉 cache_peer 210.240.125.5 parent
3128 3130 設定上層為縣網的 proxy
cache_dir ufs
/usr/local/squid/cache 100 16 256 將 # 註解拿掉 cache_access_log
/usr/local/squiid/logs/access.log 將 # 註解拿掉 cache_store_log
/usr/local/squid/logs/store.log 將 # 註解拿掉 http_access deny all 預設為 deny
把她改為 allow http_access allow all cache_effective_user nobody 將 # 註解拿掉
cache_effective_group nogroup
cache_effective_group nobody 改為 nobody 並且 # 註解拿掉
logfile rotate 7
logfile rotate 1 替換 log 檔
reference_age 1year reference_age 1 week