当前位置:网站首页>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
边栏推荐
- 实战攻防演练中的四大特点
- Left hand dreams right hand responsibilities GAC Honda not only pays attention to sales but also children's safety
- Notes on BGP part of CCNP
- |遇到bug怎么分析,专业总结分析来了
- 入职一家新公司,如何快速熟悉代码?
- 会自动化—10K,能做自动化—20K,你搞懂自动化测试没有?
- Chinese address and English address
- EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?
- Sumati gamefi ecological overview, element design in the magical world
- Android Internet of things application development (smart Park) - set sensor threshold dialog interface
猜你喜欢

Experience of epidemic prevention and control, home office and online teaching | community essay solicitation

File system - basic knowledge of disk and detailed introduction to FAT32 file system

Redis 那些事
![Search two-dimensional matrix [clever use of bisection + record solution different from inserting bisection]](/img/c9/afc03afd477bbfdd3c0dc54bacfd2d.png)
Search two-dimensional matrix [clever use of bisection + record solution different from inserting bisection]

MeterSphere開源持續測試平臺與阿裏雲雲效DevOps的集成

When they are in private, they have a sense of propriety

Intranet learning notes (5)

3年测试经验,连简历上真正需要什么都没搞明白,张口就要20k?

都2022年了,你还不了解什么是性能测试?

背了八股文,六月赢麻了……
随机推荐
Investigation on key threats of cloud computing applications in 2022
字符串数组转换为list集合
Qt中使用QDomDocument操作XML文件
File system - basic knowledge of disk and detailed introduction to FAT32 file system
June 24, 2022: golang multiple choice question, what does the following golang code output? A:1; B:3; C:4; D: Compilation failed. package main import ( “f
实战攻防演练中的四大特点
02-Epicor二次开发常用代码
Exploring the mystery of C language program -- C language program compilation and preprocessing
中信证券手机开户是靠谱的吗?安全吗
How to quickly familiarize yourself with the code when you join a new company?
write a number of lines to a new file in vim
Dataease template market officially released
Redistemplate operates redis. This article is enough (I) [easy to understand]
|遇到bug怎么分析,专业总结分析来了
Please run IDA with elevated permissons for local debugging.
When they are in private, they have a sense of propriety
Smartctl opens the device and encounters permission denied problem troubleshooting process record
tmux 如何自定义背景颜色 | How does the tmux color palette work?
The role of software security testing, how to find a software security testing company to issue a report?
Beescms website penetration test and repair comments "suggestions collection"