当前位置:网站首页>Squid 代理服务器之 ACL 访问控制
Squid 代理服务器之 ACL 访问控制
2022-06-24 22:46:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
文章目录
1. ACL 访问控制方式
- 根据源地址、目标 URL、文件类型等定义列表
格式为:acl 列表名称 列表类型 列表内容 ...- 针对已定义的 acl 列表进行限制
格式为:http_access allow 或 deny 列表名称 ...2. ACL 规则优先级
- 一个用户访问代理服务器时,Squid 会以从上至下的顺序匹配 Squid 中定义的所有规则列表,一旦匹配成功,立即停止匹配
- 所有规则都不匹配时,Squid 会使用与最后一条相反的规则
3. ACL 的定义步骤
在配置文件 squid.conf 中,ACL 访问控制通过以下两个步骤来实现:
- 通过 acl 配置项定义需要控制的条件
- 通过 http_access 对已定义的列表做 “允许” 或 “拒绝” 访问的控制
#定义访问控制列表
#用法格式如下:
acl [列表名称] [列表类型] [列表内容] […]
#常用
vim /etc/squid.conf
......
acl localhost src 192.168.126.15/32 #源地址为 192.168.126.15
acl MYLAN src 192.168.126.0/24 #客户机网段
acl destionhost dst 192.168.126.14/32 #目标地址为 192.168.126.14
acl MC20 maxconn 20 #最大并发连接 20
acl PORT port 21 #目标端口 21
acl DMBLOCK dstdomain .qq.com #目标域,匹配域内所有站点
acl BURL url_regex -i ^rtsp:// ^emule:// #以 rtsp://、emule:// 开头的 URL,-i表示忽略大小写
acl PURL urlpath_regex -i \.mp3$ \.mp4$ \.rmvb$ #以 .mp3、.mp4、.rmvb 结尾的 URL 路径
acl WORKTIME time MTWHF 08:30-17:30 #时间为周一至周五 8:30~17:30,“MTWHF”为每个星期的英文首字母4. 定义访问控制列表
格式:
acl [列表名称] [列表类型] [列表内容]列表名称:名称自定义,相当于给 acl 起个名字(有点类似于 shell 脚本变量名) 列表类型:必须使用 squid 预定义的值,对应不同类别的控制条件 列表内容:是要控制的具体对象,不同类型的列表所对应的内容也不一样,可以有多个值(以空格为分隔,为 “或” 的关系)
4.1 方法一
vim /etc/squid.conf
.......
acl localhost src 192.168.100.10/24 #源地址为192.168.184.10
acl MYLAN src 192.168.100.0/24 #客户机网段
acl destinationhost dst 192.168.226.129/32 #目标地址为192.168.184.20
acl MC20 maxconn 20 #最大并发连接20
acl PORT port 21 #目标端口21
acl DMBLOCK dstdomain .qq.com #目标域,匹配域内所有站点
acl BURL url_regex -i ^rtsp:// ^emule:// #以rtsp://. emule://开头的URL,-i表示忽略大小写
acl PURL urlpath_regex -i \.mp3$ \.mp4$ \.rmvb$ #以 .mp3、.mp4、.rmvb结尾的URL路径
acl WORKTIME time MTWHF 08:30-17:30 #时间为周一-至周五8:30~17:30, "MTWHF"为每个星期的英文首字母
第一条插入:
http_access deny host4.2 方法二
启动对象列表管理
mkdir /etc/squid
vim /etc/squid/dest.list
192.168.226.129 #Squid服务器IP
192.168.226.0/24 #任意需要的网段
vim /etc/squid.conf
......
acl destinationhost dst "/etc/squid/dest.list" #调用指定文件中的列表内容
http_access deny (或allow) destinationhost #注意,如果是拒绝列表,需要放在 http_access allow all 前面
systemctl restart squid发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151754.html原文链接:https://javaforall.cn
边栏推荐
- MeterSphere開源持續測試平臺與阿裏雲雲效DevOps的集成
- Build and train your own dataset for pig face recognition
- 当人们用互联网式的思维和视角来看待产业互联网的时候,其实已陷入到了死胡同
- ida中交叉引用的解析
- Explanation of FTP protocol
- 背了八股文,六月赢麻了……
- 入职一家新公司,如何快速熟悉代码?
- The ecosystem of the yuan universe
- Test / development programmers, 30, do you feel confused? And where to go
- Kaggle 专利匹配比赛金牌方案赛后总结
猜你喜欢
随机推荐
[day 26] given the ascending array nums of n elements, find a function to find the subscript of target in nums | learn binary search
beescms网站渗透测试和修复意见「建议收藏」
qt打包exe文件,解决“无法定位程序输入点_ZdaPvj于动态链接库Qt5Cored.dll”
Stocking but not completely stocking (daily question 2 in spring)
How to monitor the log through the easycvr interface to observe the platform streaming?
如何通过EasyCVR接口监测日志观察平台拉流情况?
Rod and Schwartz cooperated with ZhongGuanCun pan Lianyuan Institute to carry out 6G technology research and early verification
Logminer database log mining
2022年云计算应用关键威胁调查
Sumati gamefi ecological overview, element design in the magical world
Cusdis - 轻量级、隐私优先的开源评论系统 | 倾城之链
write a number of lines to a new file in vim
Do you know your ABC
How to choose a regular and safe foreign exchange trading platform?
write a number of lines to a new file in vim
Folding screen will become an important weapon for domestic mobile phones to share the apple market
【STL源码剖析】配置器(待补充)
记一次beego通过go get命令后找不到bee.exe的坑
Computing service network: a systematic revolution of multi integration
MPLS notes Part 1









