日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ACL访问控制

發布時間:2024/2/28 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ACL访问控制 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ACL訪問控制和squid日志分析工具

  • ACL訪問控制和squid日志分析工具
    • ACL訪問控制
    • ACL列表的應用
    • 反向代理網站加速
    • ACL實驗環境
  • squid日志分析工具實驗
    • 在squid服務端配置
  • squid反向代理實驗
    • 配置第一臺http服務端頁面
    • 配置第二臺http服務端頁面
    • 在squid服務器上配置
    • 在web服務器配置

ACL訪問控制和squid日志分析工具

ACL訪問控制

ACL訪問控制方式

  • 根據源地址、目標URL、文件類型等定義列表
    acl列表名稱列表類型列表內容…
  • 針對已定義的acl列表進行限制
    http_access allow或deny列表名稱…

ACL規則優先級

  • 一個用戶訪問代理服務器時,Squid會順序匹配Squid中定
    義的所有規則列表,一旦匹配成功,立即停止匹配
  • 所有規則都不匹配時,Squid會使用與最后一條相反的規則

ACL訪問控制
常用的ACL列表類型

  • src →>源地址
  • dst >自標地址
  • port→>端口
  • dstdomain>目標域
  • time →>訪問時間
  • maxconn →最大并發連接
  • ourl_regex >目標URL地址
  • Urlpath_regex→整個目標URL路徑

ACL列表的應用

最簡單的ACL控制

禁止任何客戶機使用此代理服務

[root@localhost~]# vi letclsquid.conf acKalsrc 0.0.0.0/0.0.0.0 http_access deny all

反向代理網站加速

工作機制

  • 緩存網頁對象,減少重復請求
  • 將互聯網請求輪訓或按權重分配到內網Web服務器
  • 代理用戶請求,避免用戶直接訪問Web服務器,提高安全

搭建反向代理實現加速

  • 設置網絡參數
  • 安裝部署squid服務器
  • 配置squid支持透明代理
  • 配詈防火墻
  • 測試驗證

ACL實驗環境

3臺服務器

1臺squid代理服務器 : 192.168.136.40

1臺apache服務器:192.168.136.30

1臺web客戶機 192.168.136.50

下面的實驗基于squid傳統代理基礎上配置(ps:配置squid不在贅述,如有不會請回看上一篇博客)

在squid代理服務器上配置

[root@squid network-scripts]# vim /etc/squid.conf # should be allowed acl hostlocal src 192.168.136.50/32 #增控制的是win10的地址# 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)

訪問已經拒絕

開啟服務

[root@localhost ~]# vim /etc/squid.conf #http_access deny hostlocal 注釋掉

squid日志分析工具實驗

記得把前面的acl控制web端口注釋掉

[root@squid network-scripts]# vim /etc/squid.conf #http_access deny hostlocal #acl hostlocal src 192.168.136.50/32

在squid服務端配置

解壓縮

[root@localhost ~]# tar zxvf sarg-2.3.7.tar.gz -C /opt/

安裝圖像化處理工具,gd庫

[root@squid sarg-2.3.7]# yum install gd gd-devel -y

編譯配置

[root@localhost ~]# cd squid-3.4.6/ [root@localhost squid-3.4.6]# ./configure --prefix=/usr/local/sarg \ > --sysconfdir=/etc/sarg \ > --enable-extraprotection [root@localhost squid-3.4.6]# make && make install

配置sarg服務

root@squid sarg-2.3.7]# cd /etc/sarg/ [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 no289 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@localhost sarg]# grep -v "^#" sarg.conf

創建一個文件名(不生成報告的主機)

touch /usr/local/sarg/noreport

命令可以識別

ln -s /usr/local/sarg/bin/sarg /usr/local/bin/

開啟服務(生成報告記錄)

[root@localhost sarg]# sarg SARG: 紀錄在文件: 382, reading: 100.00% SARG: 成功的生成報告在 /var/www/html/squid-reports/2020Sep07-2020Sep08

可以看到生成的記錄在哪

2020Sep07-2020Sep07在這里

[root@localhost squid-reports]# ls /var/www/html/squid-reports/ 2020Sep07-2020Sep07 images index.html

在aquid服務中安裝http展現服務

[root@localhost squid-reports]# yum -y install httpd

開啟并查看

[root@localhost squid-reports]# systemctl restart httpd[root@localhost sarg]# netstat -ntap | grep httpd tcp6 0 0 :::80 :::* LISTEN 60702/httpd

去win10客戶端查看

地址 192.168.136.40/squid-reports

點擊進去查了詳細

更換地址訪問

在squid日志服務器上配置

[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)

刷新啟動成功

squid反向代理實驗

需要3臺服務器
1臺squit代理服務器 192.168.136.40
2http服務器 編譯首頁 web01 192.168.136.30
3http服務器 編譯首頁 web02 192.168.136.88

配置第一臺http服務端頁面

[root@localhost ~]# yum -y install httpd [root@localhost ~]# vim /var/www/html/index.html <h1>this is web 01 </h1> [root@localhost ~]# systemctl restart httpd.service

配置第二臺http服務端頁面

[root@localhost ~]# yum -y install httpd [root@promote ~]# vim /var/www/html/index.html <h1> this is web 02</h1> [root@localhost ~]# systemctl restart httpd.service

在squid服務器上配置

查看一下端口有沒有被占用,因為httpd會占用80端口,必須關閉

[root@localhost ~]# netstat -ntap | grep 80 [root@localhost ~]# systemctl stop httpd

配置反向代理squid服務

[root@localhost ~]# vim /etc/squid.conf #http_port 3128 注釋監聽端口 并在下面配置 http_port 192.168.136.40:80 accel vhost vport cache_peer 192.168.136.30 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web1 cache_peer 192.168.136.88 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web2 cache_peer_domain web1 web2 www.yun.com

開啟服務

監聽端口為本地80端口

[root@localhost ~]# service squid stop [root@localhost ~]# netstat -ntap | grep squid [root@localhost ~]# service squid start 正在啟動 squid... [root@localhost ~]# netstat -ntap | grep squid tcp 0 0 192.168.136.40:80 0.0.0.0:* LISTEN 57844/squid-1)

在web服務器配置

修改端口號為80

配置wen10的DNS

c/windows/system32/drivers/etc

設置文件權限

文本打開

配置dns

ping查看是否在線

刷新一下

如果顯示不出來在配置正確的情況下,在兩臺http服務機上關閉防火墻或win10防火墻

總結

以上是生活随笔為你收集整理的ACL访问控制的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。