Apache 2.4代理外部,redirect为内部

我试图设置一个反向代理,只允许几个select的IP范围代理到一个内部主机,而我想任何其他人不在IP范围内redirect到我们的内部命名的主机。 在这个设置中,Web服务将工作,而没有VPN的人进入我们的networking将不能够导航到内部资源。 我一直试图得到这个工作没有运气,我的部分configuration目前如下:

ProxyRequests Off <Proxy *> Allow from all </Proxy> <Location /> Allow From xxx.xxx.xxx.xxx/24 1xxx.xxx.xxx.xxx/23 Deny From All ProxyPass http://server.local.corp:8000/ ProxyPassReverse http://server.local.corp:8000/ </Location> 

这个configuration似乎很好地阻止其他IP范围能够代理,但我不清楚我可以如何为其他人添加一个redirect语句。

编辑从第一个答案我的代码现在看起来像这样:

 <If "%{REMOTE_ADDR} -ipmatch 'xxx.xxx.xxx.xxx/24'"> ProxyPass / http://server.local.corp:8000/ ProxyPassReverse / http://server.local.corp:8000/ </If> 

而且apache在重新启动时会抛出以下错误:

 ProxyPass cannot occur within <If> section Action 'configtest' failed. The Apache error log may have more information. 

您需要将ProxyPass和Redirect指令包装到新引入的If语句中:<If expression> ProxyPass … </ If>“

查看http://httpd.apache.org/docs/2.4/mod/core.html#if ,了解关于If指令的更多信息,以及http://httpd.apache.org/docs/2.4/expr .html学习如何编写一个Apacheexpression式(-ipmatch似乎是你正在寻找的)

请注意,这仅在Apache httpd 2.4中有效。