溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

squidACL訪問控制,反向代理,sarg日志

發(fā)布時間:2020-06-09 17:03:00 來源:網(wǎng)絡(luò) 閱讀:161 作者:23trl 欄目:云計算

實驗環(huán)境

squid服務(wù)器 ens33:192.168.13.184
                                        ens36:192.168.10.1 (僅主機模式)
web服務(wù)器 192.168.13.151
client 192.168.10.10  (僅主機模式)

一,ACL訪問控制

1,在squid服務(wù)器上修改配置文件

[root@squid ~]# vim /etc/squid.conf  ##修改配置文件
# should be allowed
acl hostlocal src 192.168.10.10/32  ##控制hostlocal10.10的主機
# Deny requests to certain unsafe ports
http_access deny hostlocal  ##拒絕訪問
[root@squid ~]# service squid reload   ##重啟squid服務(wù)

2,在測試機上訪問web網(wǎng)頁

squidACL訪問控制,反向代理,sarg日志

二,sarg日志

1,在squid服務(wù)器上安裝sarg

[root@squid ~]# mount.cifs //192.168.100.3/LNMP-C7 /mnt/  ##掛載
Password for root@//192.168.100.3/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庫
[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  ##編譯安裝

2,修改sarg配置文件

[root@squid sarg-2.3.7]# vim /etc/sarg/sarg.conf  ##修改sarg配置文件
##將下面的模塊修改開啟
access_log /usr/local/squid/var/logs/access.log  ##指定訪問日志文件
title "Squid User Access Reports"  ##網(wǎng)頁標題
output_dir /var/www/html/squid-reports  ##報告輸出目錄
user_ip no  ##使用用戶名顯示
exclude_hosts /usr/local/sarg/noreport  ##不計入排序的站點列表文件
topuser_sort_field connect reverse  
##top排序中有連接次數(shù),訪問字節(jié),降序排列,升序是normal
overwrite_report no  ##同名日志是否覆蓋
mail_utility mailq.postfix  ##發(fā)送郵件報告命令
charset UTF-8  ##使用字符集
weekdays 0-6  ##top排行的時間周期
hours 0-23  ##top排行的時間周期
www_document_root /var/www/html  ##網(wǎng)頁根目錄
[root@squid ~]# sarg   ##生成報告
SARG: 紀錄在文件: 91, reading: 100.00%
SARG: 成功的生成報告在 /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  ##開啟服務(wù)
[root@squid squid-reports]# systemctl stop firewalld.service   ##關(guān)閉防火墻
[root@squid squid-reports]# setenforce 0

3,用測試機訪問網(wǎng)頁查看訪問記錄

squidACL訪問控制,反向代理,sarg日志

##周期性計劃任務(wù)執(zhí)行每天生成報告crontab
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)

squidACL訪問控制,反向代理,sarg日志

三,squid反向代理

squid服務(wù)器 ens33:192.168.13.184
                                        ens36:192.168.10.1 (僅主機模式)
web1服務(wù)器 192.168.13.151
web2服務(wù)器 192.168.13.185
client 192.168.10.10  (僅主機模式)

1,在web1服務(wù)器上編輯一個網(wǎng)頁內(nèi)容

[root@web ~]# cd /var/www/html/
[root@web html]# vim index.html  ##編輯網(wǎng)頁內(nèi)容
<h2>this is test web!</h2>

2,在測試機上訪問網(wǎng)頁

squidACL訪問控制,反向代理,sarg日志

3,在web2服務(wù)器上編輯一個網(wǎng)頁內(nèi)容

[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)頁內(nèi)容
[root@web2 html]# vim index.html
<h2>this is test2 web!</h2>
[root@web2 html]# systemctl start httpd.service 

4,在squid服務(wù)上配置反向代理

[root@localhost squid]# vim /etc/squid.conf
# Squid normally listens to port 3128
http_port 192.168.13.184:80 accel vhost vport ##監(jiān)控本機80端口
cache_peer 192.168.13.151 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web1
##節(jié)點服務(wù)器1最大訪問30,權(quán)重1,別名web1
cache_peer 192.168.13.185 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web1
cache_peer_domain web1 web2 www.yun.com  ##訪問yun.com匹配web1,web2節(jié)點
[root@localhost squid]# service squid restart  ##重啟squid服務(wù)

5,在測試機的admin用戶下配置解析域名地址,并設(shè)置代理

squidACL訪問控制,反向代理,sarg日志
squidACL訪問控制,反向代理,sarg日志
squidACL訪問控制,反向代理,sarg日志
squidACL訪問控制,反向代理,sarg日志

謝謝閱讀!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI