sarg日誌
acl從上向下一次匹配,匹配即中止,並執行匹配的動做
因此容許全部或者禁止全部的參數,須要設置在acl的後面
http_access allow all
http_access deny all
先了解acl訪問控制
src 源地址 dst 目標地址
列表的定義php
[root@squid network-scripts]# vim /etc/squid.conf # should be allowed acl hostlocal src 192.168.10.100/32 #增長 。。。 # Deny requests to certain unsafe ports http_access deny hostlocal #增長 [root@squid network-scripts]# service squid reload [root@squid network-scripts]# netstat -natp | grep 3128tcp 0 0 192.168.10.1:3128 0.0.0.0:* LISTEN 101064/(squid-1)
注意,squid的源地址是客戶端,目標地址是web端
此時切換到win客戶機查看時候被限制(記得隨時清空歷史記錄)
/etc/squid.conf文件中的deny/allow是從上而下去讀取配置,一旦匹配上,就不執行下面操做
接下來開始配置日誌
首先刪除剛纔的限制,以便於後面的驗證css
[root@squid network-scripts]# service squid reload
[root@squid network-scripts]# cd /abc [root@squid abc]# tar zxvf sarg-2.3.7.tar.gz -C /opt [root@squid abc]# cd /opt/sarg-2.3.7/
安裝sarg前須要先安裝圖像化處理工具,即gd庫html
[root@squid sarg-2.3.7]# yum install gd gd-devel -y [root@squid sarg-2.3.7]# ./configure --prefix=/usr/local/sarg \ --sysconfdir=/etc/sarg \ --enable-extraprotection [root@squid sarg-2.3.7]# make && make install
[root@squid sarg-2.3.7]# cd /etc/sarg/ [root@squid sarg]# ls css.tpl exclude_codes sarg.conf user_limit_block [root@squid sarg]# vim sarg.conf 7 access_log /usr/local/squid/var/logs/access.log //squid的訪問日誌位置 25 title "Squid User Access Reports" //網頁標題 120 output_dir /var/www/html/squid-reports //分析報告存放位置 178 user_ip no //不使用IP代替用戶ID 184 topuser_sort_field connect reverse //升序排列 190 user_sort_field connect reverse 206 exclude_hosts /usr/local/sarg/noreport #這個文件待會須要建立,裏面存放的是不生成報告的主機 257 overwrite_report no 289 mail_utility mailq.postfix //指定發郵件命令 434 charset UTF-8 518 weekdays 0-6 //指定top排序星期週期 525 hours 0-23 //指定top排序時間週期 633 www_document_root /var/www/html //網頁根目錄
[root@squid sarg]# touch /usr/local/sarg/noreport //創建不生成報告的主機列表文件 [root@squid sarg]# ln -s /usr/local/sarg/bin/sarg /usr/local/bin/ //建立命令軟鏈接 [root@squid sarg]# sarg //開啓 SARG: Records in file: 238, reading: 100.00% SARG: Successful report generated on /var/www/html/squid-reports/2020Feb02-2020Feb02 [root@squid sarg]# cd /var/www/html/ [root@squid html]# ls index.php sarg-php squid-reports [root@squid html]# cd squid-reports/ [root@squid squid-reports]# ls 2020Feb02-2020Feb02 images index.html [root@squid squid-reports]# rpm -q httpd httpd-2.4.6-90.el7.centos.x86_64 [root@squid squid-reports]# systemctl restart httpd.service
能夠使用週期性計劃任務執行crontab -e,天天生成日誌報告web
[root@squid squid-reports]# sarg -l /usr/local/squid/var/logs/access.log -o /var/www/html/squid-reports/ -z -d $(date -d "1 day ago" +%d/%m/%Y)-$(date +%d/%m/%Y)