Squid 代理 - 执行与我想要的完全相反的操作 - 反向允许/拒绝

Squid 代理 - 执行与我想要的完全相反的操作 - 反向允许/拒绝

我已经设置了这个 Squid 配置文件,但它似乎在做与我想要的完全相反的事情。它阻止了来自 65.134.25.35 和 122.45.36.27 的流量。并允许所有其他客户端在 80 上连接。这正常吗?我第一次使用 Squid。注意:真实 IP 已略有改动。

acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8            # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12         # RFC1918 possible internal network
#acl localnet src 192.168.0.0/16        # RFC1918 possible internal network
acl localhet src 197.202.60.0/24        # My Organization
acl localnet src 197.202.61.0/24        # My Organization
acl localnet src 197.202.62.0/24        # My Organization
acl localnet src 197.202.63.0/24        # My Organization
#acl localnet src fc00::/7               # RFC 4193 local private network range
#acl localnet src fe80::/10              # RFC 4291 link-local (directly plugged) machines

acl safe_ports port 80                  # http

acl CONNECT method CONNECT
acl allow dstdomain  .somecompany.com .anothercompany.com
acl all_others dst all
acl myclients src 65.134.25.35 122.45.36.27

# Recommended minimum Access Permission configuration:
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
#http_access deny !safe_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
http_access deny to_localhost

# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS

# Disable Caching
cache deny all
#pass accelerated domains to the peer
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access allowed
http_access deny all_others
#http_access allow whitelist
http_access allow myclients
# Squid normally listens to port 3128
http_port 80
# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
# Add any of your own refresh_pattern entries above these.
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

squid.conf 中 http_access 行的顺序很重要。您已deny all_others在 之前应用了 ,allow myclients这是 的 ACL。http_access65.134.25.35设置按顺序处理。一旦 ACL 匹配,请求将被允许或拒绝,规则处理将停止。myclients ACL 永远不会做任何有用的事情,因为所有内容都已被拒绝。因此,您应该将您创建的任何 ACL 移到注释 上方# And finally deny...

# from where browsing should be allowed
http_access allow localnet
http_access allow localhost
#http_access allow whitelist
http_access allow myclients
# And finally deny all other access to this proxy
#http_access allowed
http_access deny all_others

答案2

这些 http_access 行很混乱。

您允许通过本地网络进行访问,然后拒绝所有人访问,然后再次允许单个客户端访问。

请参阅此链接以了解如何排除 ACL 故障:http://wiki.squid-cache.org/SquidFaq/SquidAcl#I_set_up_my_access_controls.2C_but_they_don.27t_work.21__why.3F

相关内容