当前位置:网站首页>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 host
4.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
边栏推荐
- Day 04 - file IO
- 折叠屏将成国产手机分食苹果市场的重要武器
- 产业互联网的概念里有「互联网」字眼,但却是一个和互联网并不关联的存在
- Lizuofan, co-founder of nonconvex: Taking quantification as his lifelong career
- 如何通过EasyCVR接口监测日志观察平台拉流情况?
- Longest continuous sequence [diffusion method + space for time]
- Experience of epidemic prevention and control, home office and online teaching | community essay solicitation
- JS array object to object
- 做软件安全测试的作用,如何寻找软件安全测试公司出具报告?
- Four characteristics of actual attack and defense drill
猜你喜欢
背了八股文,六月赢麻了……
What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
软件测试人员的7个等级,据说只有1%的人能做到级别7
Fake wireless speakers in stores? Sony responded: the product has reserved a wired connection interface, which can be used in complex scenarios
Intranet learning notes (5)
JS array object to object
MeterSphere开源持续测试平台与阿里云云效DevOps的集成
DDD概念复杂难懂,实际落地如何设计代码实现模型?
MeterSphere開源持續測試平臺與阿裏雲雲效DevOps的集成
转行软件测试2年了,给还在犹豫的女生一点建议
随机推荐
放养但没有完全放养(春季每日一题 2)
Sumati GameFi生态纵览,神奇世界中的元素设计
Intranet learning notes (5)
What are the SQL aggregate functions
Multimodal emotion recognition_ Research on emotion recognition based on multimodal fusion
Smartctl opens the device and encounters permission denied problem troubleshooting process record
How can Huatai Securities open an account to achieve one in ten thousand? Are securities accounts safe and reliable
1-6搭建Win7虚拟机环境
Sumati gamefi ecological overview, element design in the magical world
EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?
Basic layout -qhboxlayout class, qvboxlayout class, qgridlayout class
What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
【FPGA】串口以命令控制温度采集
内网学习笔记(5)
记一次beego通过go get命令后找不到bee.exe的坑
Day 04 - file IO
Cusdis - lightweight, privacy first open source comment system | chain of the city
产业互联网的概念里有「互联网」字眼,但却是一个和互联网并不关联的存在
3年测试经验,连简历上真正需要什么都没搞明白,张口就要20k?
The role of software security testing, how to find a software security testing company to issue a report?