绕过 Squid 域名

绕过 Squid 域名

我正在使用带有 adzap 的 squid,squid/adzap 可能不会缓存特定域,例如 cnn.com。这是我的squid.conf文件:

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32
#acl localhost src ::1/128
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
#acl to_localhost dst ::1/128

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 192.168.1.0/24
acl localnet src 192.168.2.0/24

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

#
# 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

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_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
#

# 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 deny all

# Squid normally listens to port 3128
http_port xxx.xxx.xxx.yyy:3128 transparent
visible_hostname proxyserver.local

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 1024 16 256

# 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
access_log /var/log/squid/squid.log squid
access_log syslog squid
redirect_program /usr/local/adzap/scripts/wrapzap

固定使用

acl allow_domains dstdomain www.cnn.com
always_direct allow allow_domains

答案1

我很惊讶它always_direct居然能起作用。正如其他人所说,这只会影响缓存层次结构,而您似乎没有使用缓存层次结构。

如果您想要控制缓存,那么正确的配置选项是cache(或no_cache,取决于您正在运行的 squid 版本)。

例如

Acl dontcache dstdomain .cnn.com
Cache deny dontcache
Cache allow all

答案2

Squid 指令总是直接表示对于指定的 ACL,始终直接连接到它们,并且从不连接到上游缓存。许多过滤代理都设置为上游缓存,因此过滤器不必担心缓存(它将缓存委托给 Squid)。

你的例子

acl allow_domains dstdomain www.cnn.com
always_direct allow allow_domains

定义一个名为的访问控制列表allow_domains,并将 www.cnn.com 添加到其中。(您可能还想将其更改为,以.cnn.com允许其他 CNN 网站,但不仅仅是带有该后缀的任何网站,例如“malwarecnn.com”)。

然后,always_direct allow ACL_NAME 将告诉 Squid 忽略该域的转发器。

(如果您回答自己的问题,请以答案的方式回答。否则,有人会来为未来的读者添加更多细节。:)

答案3

总是直接用于指定应该总是由 Squid 转发到原始服务器无需使用任何对等点。这与缓存无关。您必须使用类似下面的代码来代替 always_direct

acl bypass_caching dstdomain cnn.com
cache deny bypass_caching

TAG:缓存 - ACL 元素列表,如果匹配,则会导致请求无法从缓存中得到满足,并且回复不会被缓存。换句话说,使用它来强制某些对象永远不会被缓存。您必须使用单词“DENY”来指示 ACL 名称不应被缓存

相关内容