如何配置mod_proxy阻止除一个站点之外的所有站点 [英] How to configure mod_proxy to block every site except one

查看:67
本文介绍了如何配置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?

谢谢

-安德鲁

推荐答案

在apache 2.2上,您需要具有2个proxy部分.

On apache 2.2 you need to have 2 proxy sections.

ProxyRequests On
ProxyVia On

# block all domains except our target
<ProxyMatch ^((?!www\.proxytarget\.com).)*$>
   Order deny,allow
   Deny from all
</ProxyMatch>

# here goes your usual proxy configuration...
<ProxyMatch www\.proxytarget\.com >
   Order deny,allow
   Deny from all
   Allow from 127.0.0.1
</ProxyMatch>

在Apache 2.4上,这会容易得多,因为您可以使用如果为指令而不是该正则表达式,则可以将域名的匹配取反.

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.

注意:我从使用regexp反转匹配中获得了该regexp

这篇关于如何配置mod_proxy阻止除一个站点之外的所有站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆