我在Debian上使用Squid 3.4,我想知道如何在禁用其他的子网站时允许某些子url。
特别是,我想禁止访问reddit.com/*,但允许访问reddit.com/r/foo/*和reddit.com/r/foo/
acl bad url_regex reddit\.com.* acl good url_regex reddit\.com.*foo* http_access deny bad http_access allow good ... http_access allow localnet http_access allow localhost http_access deny all
这段代码似乎不起作用,reddit.com上的所有内容都会被阻止。 我怎样才能得到我想要的configuration?
编辑:更新的configuration仍然不起作用:
acl good url_regex http(s)?://(www\.)?reddit\.com/r/foo.* acl bad url_regex http(s)?://(www\.)?reddit\.com.* http_access allow good http_access deny bad ... http_access allow localnet http_access allow localhost http_access deny all
这与前面的代码有相反的效果; 它允许访问所有的reddit.com(我不想)。
对于像我这样的人,在这个post中找不到答案。 原因是squid无法看到HTTPS请求的完整URL,只能看到域名。
您只能为HTTP连接执行url_regex。 您必须为HTTPS连接执行dstdomain。
这是代理连接的方式,而不是一个鱿鱼问题。
订单很重要。 把允许行放在拒绝之前。
此外url_regex匹配整个URL包括http://所以你需要改变你的正则expression式。 请记住在更改之后重新启动或重新加载squid。
在这里描述; http://wiki.squid-cache.org/SquidFaq/SquidAcl
我目前的设置是这样的;
acl special_client src 10.1.255.93 acl special_url url_regex ^http://ppa.launchpad.net/adiscon/v8-devel/ubuntu/.* http_access allow special_client special_url http_access deny special_url
我想你正在寻找这样的东西:
http_access allow good http_access deny bad !good
因为实际上goodexpression式匹配badexpression式,所以你需要在第二行使用AND连接器。
请注意,你可以用这行来debuggingacl:
debug_options ALL,1 28,3 33,2