如何配置 mod_proxy 以阻止除一个网站之外的所有网站
我正在尝试设置 mod 代理来阻止除特定域之外的所有流量。我可以将其配置为使用 ProxyBlock 指令阻止各个域,并且可以使用 ProxyBlock * 阻止所有内容。有没有一种方法可以阻止除一个域之外的所有域?
谢谢,
-安德鲁
I'm trying to set up mod proxy to block all traffic except to a specific domain. I can configure it to block individual domains using the ProxyBlock directive, and I can block everything using ProxyBlock *. Is there a way to block everything but one domain?
Thanks,
-Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 apache 2.2 上,您需要有 2 个
proxy
部分。在 apache 2.4 上,这会更容易,因为您可以使用 If 指令< /a> 而不是该正则表达式来反转域名的匹配。
注意:我从 Invert match with regexp 得到了该正则表达式
On apache 2.2 you need to have 2
proxy
sections.On apache 2.4 it would be much easier because you could use the If directive instead of that regexp to invert the match for the domain name.
Note: I got that regexp from Invert match with regexp
尝试:
看看是否有效。
编辑:从头开始。我认为你必须在这里使用 mod_rewrite 发挥创意(基本参考位于 http:// /httpd.apache.org/docs/current/rewrite/proxy.html):
尝试一下吗?
Try:
See if that works.
EDIT: scratch that. I think you have to get creative here with mod_rewrite (the basic reference is at http://httpd.apache.org/docs/current/rewrite/proxy.html):
Try that?
Apache 2.4:这对我有用:首先拒绝一切,然后有选择地授予。
请注意,HTTPS 需要第二个 ProxyMatch(带有 :443),否则您的请求将得到:
意味着您的 https 已通过,但 SSL 隧道被拒绝。
这适用于 Apache 侦听 :80,使用以下请求
但不包含
这是必不可少的,因为否则您可以通过伪造的查询字符串参数绕过白名单。
Apache 2.4: this worked for me: deny everything first then grant selectively.
Note the second ProxyMatch (with the :443) is required for HTTPS because else your request gets:
meaning your https went through, but the SSL tunnel is rejected.
This works with Apache listening on :80, using the following request
but not with
which is essential, because otherwise you can circumvent the whitelisting by means of a bogus querystring parameter.
试试这个代码:
Try this code: