本LAB主角為使用者帳戶驗證存取Squid Server配置,與佈署SARG監視企業內部使用者
瀏覽網站紀錄(Ex:是否上班晃神,不懷好意連結到與工作無相關網站...等等,
然候,我們可以透過Squid 封鎖User前往facebook,噗浪..等等Web Site
當配置SARG完後將可一覽無疑企業內部員工透過瀏覽器的歷程紀錄)
本LAB 配置 以Digest 驗證使用者存取Proxy Server 與 SARG配置以掌握員工使用瀏覽器狀況
CentOS 5.5 : Squid(已安裝2.6.1) ,本例將至官網更新截至目前發行最新版本Squid(3.1.8),
Cache Proxy, IP=192.168.0.171(drbd1)
可參考官方RPM版本Squid 發佈並預先下載 squid-3.1.8-1.el5.i386.rpm
shell> rpm -Uvh squid-3.1.8-1.el5.i386.rpm #更新目前SQUID Ver. 至 3.1.8
http://people.redhat.com/jskala/squid/squid-3.1.8-1.el5/i386/squid-3.1.8-1.el5.i386.rpm
Windows XP: 將測試使用digest驗證登入Squid
(1) 編輯 /etc/squid/squid.conf 組態支援digest 使用帳戶/密碼登入驗證
vi /etc/squud/squid.conf #請於空白處插入以下組態
auth_param digest program /usr/lib/squid/digest_pw_auth /etc/squid/proxy_pwd
auth_param digest children 5
auth_param digest realm Squid proxy-caching web server
auth_param digest nonce_garbage_interval 5 minutes
auth_param digest nonce_max_duration 30 minutes
auth_param digest nonce_max_count 50
#建立帳號密碼對應檔
vi /etc/squid/proxy_pwd
keynes:Rr678B #帳號與密碼設定方式如左
# 上述第一行,我們將帳號/密碼檔案路徑指定為 /etc/squid/proxy_wd
接者我們需配置,當使用者存取Proxy時,必需進行驗證的ACL 規則設置與套用
acl localnet src 192.168.0.0/24 #定義允許企業內部員工存取Proxy時的網段
acl auth proxy_auth REQUIRED #定義auth,定義使用者存取proxy時需接受帳密驗證
http_access allow auth #allow auth
http_access allow localnet #allow localnet
http_access deny all
#上述配置完成後請手動重新啟動Squid,使其生效
(2.)本LAB使用截至目前發佈最新: sarg.2.3.1(Redhat Ver.).進行編譯與安裝
tar zxvf sarg-2.3.1.tar.gz
cd sarg-2.3.1/
/configure --prefix=/usr/local/sarg \
--bindir=/usr/local/sarg/bin \
--htmldir=/var/www/html/sarg \
make && make install
組態SARG設定檔 : /usr/local/sarg/etc/sarg.conf #本Lab不使用繁中化檔
language English
access_log /var/log/access.log.0 #指定分析log擋案路徑
title "Squid User Access Reports"
temporary_dir /tmp
output_dir /var/www/html/sarg #輸出分析資料之資料夾路徑
overwrite_report no
mail_utility /bin/mail
topsites_num 100
exclude_codes /usr/local/sarg/etc/exclude_codes
max_elapsed 28800000
charset UTF-8 #在此選擇UTF8
接著初步手動輸出SARG分析資料!!!
shell> /usr/local/sarg/bin/sarg -l /var/log/squid/access.log.0 /tmp -o /var/www/html/sarg
(3.)驗證Digest 帳戶驗證登入與SARG資料分析
設定XP帳戶_192.168.0.198(keynes) , 存取SQUID設定,http_port我們已變更為8888
接者打開Chrome瀏覽器: 下圖可知立即彈出要求使用者驗證帳戶與密碼
若輸入帳密失敗,將Show 出下圖背景 "ERROR Cache 存取被拒絕" 字樣
SARG 統計資料分別: 於網址列輸入 http://drbd1/sarg
首頁檢視:
由於我們剛使用keyens此帳號/密碼登入,由下圖我們可以看到紀錄與分析狀況
點選keynes 進一步檢視與分析: 顯示使用者瀏覽網站的紀錄
Authentication Failures: 檢視驗證失敗紀錄
最後我們可以"USER & SITE " 分類哪位使用者,瀏覽過哪些網站
LAB 設計參考技術資料:
Linux 系統安全防護與建置/碁峰
不自量力的Weithenn http://www.weithenn.org/
補充> 排程執行: 編輯SARG Rotate 與 定期執行Output SARG 分析資料
shell> crontab -e
0 20 * * * root /usr/sbin/squid -k rotate
0 21 * * * root /usr/local/sarg/bin/sarg -l /var/log/squid/access.log.0 /tmp -o /var/www/html/sarg