您好,登錄后才能下訂單哦!
acl 列表名稱(chēng) 列表類(lèi)型 列表內(nèi)容 ...
http_access allow或deny 列表名稱(chēng) ...
squid服務(wù)器IP地址:ens33:192.168.80.184
ens36:192.168.10.1 (僅主機(jī)模式)
web服務(wù)器IP地址:192.168.80.151
client客戶(hù)端IP地址:192.168.10.10 (僅主機(jī)模式)
root@squid ~]# vim /etc/squid.conf //修改配置文件
# should be allowed
acl hostlocal src 192.168.10.10/32 //控制hostlocal10.10的主機(jī)
# Deny requests to certain unsafe ports
http_access deny hostlocal //拒絕訪問(wèn)
[root@squid ~]# service squid reload //重啟squid服務(wù)
[root@squid ~]# mount.cifs //192.168.80.2/LNMP-C7 /mnt/ //掛載
Password for root@//192.168.80.2/LNMP-C7:
[root@squid ~]# cd /mnt/
[root@squid mnt]# tar zxvf sarg-2.3.7.tar.gz -C /opt/ //解壓
[root@squid mnt]# cd /opt/sarg-2.3.7/
[root@squid sarg-2.3.7]# yum install gd gd-devel -y //安裝gd庫(kù)
[root@squid sarg-2.3.7]# ./configure --prefix=/usr/local/sarg \ //安裝路徑
> --sysconfdir=/etc/sarg \ //指定配置文件位置
> --enable-extraprotection //開(kāi)啟安全防護(hù)
[root@squid sarg-2.3.7]# make && make install //編譯安裝
[root@squid sarg-2.3.7]# vim /etc/sarg/sarg.conf //修改sarg配置文件
access_log /usr/local/squid/var/logs/access.log //開(kāi)啟指定訪問(wèn)日志文件
title "Squid User Access Reports" //網(wǎng)頁(yè)標(biāo)題
output_dir /var/www/html/squid-reports //報(bào)告輸出目錄
user_ip no //使用用戶(hù)名顯示
exclude_hosts /usr/local/sarg/noreport //不計(jì)入排序的站點(diǎn)列表文件
topuser_sort_field connect reverse //top排序中有連接次數(shù),訪問(wèn)字節(jié),降序排列,升序是normal
overwrite_report no //同名日志是否覆蓋
mail_utility mailq.postfix //發(fā)送郵件報(bào)告命令
charset UTF-8 //使用字符集
weekdays 0-6 //top排行的時(shí)間周期
hours 0-23 //top排行的時(shí)間周期
www_document_root /var/www/html //網(wǎng)頁(yè)根目錄
[root@squid ~]# sarg //生成報(bào)告
SARG: 紀(jì)錄在文件: 91, reading: 100.00%
SARG: 成功的生成報(bào)告在 /var/www/html/squid-reports/2019Dec11-2019Dec12
[root@squid sarg-2.3.7]# cd /var/www/html/squid-reports/ //切換到html目錄下
[root@squid squid-reports]# ls
2019Dec11-2019Dec12 images index.html
[root@squid squid-reports]# yum install httpd -y //安裝httpd服務(wù)
[root@squid squid-reports]# systemctl start httpd.service //開(kāi)啟服務(wù)
[root@squid squid-reports]# systemctl stop firewalld.service //關(guān)閉防火墻
[root@squid squid-reports]# setenforce 0 //關(guān)閉selinux
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)
squid服務(wù)器IP地址:ens33:192.168.80.184
ens36:192.168.10.1 (僅主機(jī)模式)
web1服務(wù)器IP地址:192.168.80.151
web2服務(wù)器IP地址: 192.168.80.185
client客戶(hù)端IP地址:192.168.10.10 (僅主機(jī)模式)
root@web ~]# cd /var/www/html/
[root@web html]# echo "<h2>this is test web!</h2>" > index.html
[root@web2 ~]# systemctl stop firewalld.service //關(guān)閉防火墻
[root@web2 ~]# setenforce 0
[root@web2 ~]# yum install httpd -y //安裝httpd服務(wù)
[root@web2 ~]# cd /var/www/html/ //創(chuàng)建網(wǎng)頁(yè)內(nèi)容
[root@web2 html]# echo "<h2>this is test2 web!</h2>" > index.html
[root@web2 html]# systemctl start httpd.service
[root@localhost squid]# vim /etc/squid.conf
# Squid normally listens to port 3128
http_port 192.168.80.184:80 accel vhost vport //監(jiān)控本機(jī)80端口
cache_peer 192.168.80.151 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web1 //節(jié)點(diǎn)服務(wù)器1最大訪問(wèn)30,權(quán)重1,別名web1
cache_peer 192.168.80.185 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web1
cache_peer_domain web1 web2 www.yun.com //訪問(wèn)yun.com匹配web1,web2節(jié)點(diǎn)
[root@localhost squid]# service squid restart //重啟squid服務(wù)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。