我已经阅读了很多教程和官方文档,但建议的方法对我不起作用。
我在我的组织中设置了一个鱿鱼代理(Squid Cache:版本4.10,ubuntu 18.04.4 LTS),它非常适合我的用例。我遇到了两个问题,但会一次关注一个问题。
用户可以使用代理访问互联网,但从日志中,我看到内部 LAN IP 是通过 Web 代理访问的。 我想限制用户使用互联网,而不是内部 LAN IP。在网络代理上我已经设置了规则,但都不起作用。
acl 限制目标子网络 dst 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
acl strict_destination_IP dst 10.50.21.135
http_访问拒绝restricted_destination_IP http_access拒绝restricted_destination_subnetworks
测试- 从服务器 10.50.40.18,我运行以下命令,得到 200 OK,并且我可以在 Web 代理上看到日志为 200/TCP_MISS。
curl -s -o /dev/null -I -w "%{http_code} “ -k http://10.50.21.135:8585 200
理想情况下,我的curl请求应该被阻止,但在这种情况下却没有。
如果我做错了什么,有人可以纠正我吗?
完整配置
acl allowed_subnetworks src "/etc/squid/allowed_subnetworks_list.txt"
acl restricted_destination_subnetworks dst 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
acl restricted_destination_IP dst 10.50.21.135
acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump splice all
acl localnet src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8 # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10 # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16 # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12 # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16 # RFC 1918 local private network (LAN)
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow allowed_subnetworks
http_access deny restricted_destination_IP
http_access deny restricted_destination_subnetworks
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_access deny all
http_port 3128 ssl-bump
cache_dir ufs /var/spool/squid 3000 16 256
coredump_dir /var/spool/squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
谢谢
访问列表规则按照写入顺序进行检查。一旦其中一个规则匹配,列表搜索就会终止。 https://wiki.squid-cache.org/SquidFaq/SquidAcl#access-lists
因此,您应该尝试像这样切换顺序:
acl CONNECT method CONNECT
http_access deny restricted_destination_IP
http_access deny restricted_destination_subnetworks
http_access allow allowed_subnetworks