/etc/squid/squid.conflinux
定义语法:安全
acl aclname acltype string服务器
acl aclname acltype "file"网站
src 定义来源地址 (即用户的客户机IP地址);ui
acl aclname src ip-address/netmaskurl
acl aclname src addr1-addr2/netmaskspa
dst定义目标地址 (即用户请求的网站IP地址):代理
acl aclname dst ip-address/netmaskip
port用于指定访问端口string
acl aclname port 80 1024
acl aclname port 0-1024
url-regex 用于限制网址中的关键词:
acl aclname url_regex [-i] pattern
proto 用于定义要代理的协议:
acl aclname proto HTTP FTP
method 用于制定请求的方法:
acl aclname method GET POST
访问控制列表有多个规则条目组成,根据指定的条件来容许或限制访问请求,匹配顺序会由上至下,一旦匹配则当即结束,一般会在控制列表的最下面写上 " deny all " 或者 " allow all " 来避免安全隐患。
实战操做:
仅容许192.168.0.10的主机使用本笃 Squid 服务 ,拒绝其他主机
acl client src 192.168.0.10
http_access allow client
http_access deny all
拒绝客户机使用代理服务器访问带有关键词 " linux " 的网站
acl deny_keyword url_regex -i linux
http_access deny deny_keyword
拒绝客户机使用代理服务器访问 " 京东 " 网站
acl deny_url url_regex https://www.jd.com
http_access deny deny_url
禁止客户机代理服务器下载 MP3 与 rar 为后缀的文件
acl badfile urlpath_regex -i \.mp3$ \.rar$
http_access deny badfile