squid :阻止目标子网或 IP 地址

squid :阻止目标子网或 IP 地址

我已经阅读了许多教程和官方文档,但建议的方法对我来说不起作用。

我已经在组织中设置了 Squid 代理(Squid Cache:版本 4.10,ubuntu 18.04.4 LTS),它非常适合我的用例。我遇到了两个问题,但我会一次关注一个。

用户可以使用代理访问互联网,但从日志中,我看到内部 LAN IP 是通过 Web 代理访问的。我想限制用户使用互联网,而不是内部 LAN IP。我在 Web 代理上设置了规则,但都不起作用。

acl 限制目标子网络目标 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 acl 限制目标 IP 目标 10.50.21.135

http_access 拒绝 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} \n" -khttp://10.50.21.135:8585200

理想情况下,我的 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

谢谢

答案1

您的 http_access 行的顺序错误。安全隐患

http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
http_access allow allowed_subnetworks
http_access deny restricted_destination_IP
http_access deny restricted_destination_subnetworks 

#
# INSERT YOUR OWN RULE(S) BEFORE THESE TO ALLOW ACCESS FROM YOUR CLIENTS
#
http_access allow localhost
http_access deny all

相关内容