当前位置:网站首页>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
边栏推荐
- It's 2022, and you still don't know what performance testing is?
- 当一个接口出现异常时候,你是如何分析异常的?
- 华为、阿里等大厂程序员真的好找对象吗?
- 股票开账户如何优惠开户?手机开户是安全么?
- Pit entry machine learning: I. Introduction
- MCN机构遍地开花:博主和作者要谨慎签约、行业水很深
- 中文地址与英文地址
- How can Huatai Securities open an account to achieve one in ten thousand? Are securities accounts safe and reliable
- 【移动端】手机界面的设计尺寸
- 文件系统 -- 磁盘基础知识和FAT32文件系统详细介绍
猜你喜欢

The role of software security testing, how to find a software security testing company to issue a report?

jwt

内网学习笔记(7)

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

常用的软件测试工具清单,请查收。

左手梦想 右手责任 广汽本田不光关注销量 还有儿童安全

一线城市软件测试工资——你拖后腿了吗

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

业务与技术双向结合构建银行数据安全管理体系

Fatigue liée à l'examen du marché secondaire des médicaments innovants: succès clinique de la phase III et approbation du produit
随机推荐
Talking about the advantages of flying book in development work | community essay solicitation
Hashcat 的使用
Fatigue liée à l'examen du marché secondaire des médicaments innovants: succès clinique de la phase III et approbation du produit
How to get the picture outside the chain - Netease photo album [easy to understand]
[day 26] given the ascending array nums of n elements, find a function to find the subscript of target in nums | learn binary search
Specific list of regular and safe domestic stock trading account opening
入职一家新公司,如何快速熟悉代码?
When they are in private, they have a sense of propriety
When an interface has an exception, how do you analyze the exception?
Android物联网应用程序开发(智慧园区)—— 设置传感器阈值对话框界面
Award winning interface control development kit devaxpress v22.1 officially announced
How to quickly familiarize yourself with the code when you join a new company?
Smartctl 打开设备遇到 Permission denied 问题排查过程记录
都2022年了,你还不了解什么是性能测试?
Do you know your ABC
如何选择正规安全的外汇交易平台?
年已过半,年终立的Flag实现了几个?
Software testing salary in first tier cities - are you dragging your feet
Stocking but not completely stocking (daily question 2 in spring)
02 common codes for Epicor secondary development