我正在使用Apache Reverse Proxy ,以下是一些Apache Virtual Hostconfiguration
ProxyRequests Off <Proxy *> AddDefaultCharset off Order deny,allow Allow from all </Proxy> ProxyVia On ProxyRequests Off ProxyPreserveHost On proxyPass / ajp://127.0.0.1:8009/
现在我想要限制像http://mysite.com/admin/tools这样的request url ,它只允许从特定的IP address访问。 我怎样才能做到这一点?
编辑:
至于上述要求这个答案工作正常,假设我想允许从一个或两个IP's访问admin URL和其余的IP's我想redirect到index页面,而不是显示forbidden error ,我怎么能得到这个?
你使用的是什么版本的Apache? 限制访问基于URL的资源的一种方法是使用
例如:
<Location /admin/tools> Order Deny,Allow Deny from all Allow from 192.168.1.34 </Location>
至于上述要求这个答案工作正常,假设我想允许从一个或两个IP访问pipe理员的URL和其余的IP我想redirect到索引页面,而不是显示禁止的错误,我怎么能得到这个?
要展开@ krist-van-besien的答案,你可以使用ErrorDocument for 403 Forbidden这样的帮助来做到这一点:
<Location /admin/tools> Order Deny,Allow Deny from all Allow from 192.168.1.34 ErrorDocument 403 /index.php </Location>
请注意,用户应该有权限查看您将其redirect到的页面。 欲了解更多信息,你可以检查这个问题: 允许阻止IP查看403 ErrorDocument
展开此scheme以应用于REST风格的Web服务端点与从网页调用端点。
有没有办法代理来自本地服务器的网页的请求,并将它们转发到Web服务地址,同时允许本地内部networking请求(开发人员)访问Web服务端点,但是仍然限制直接的外部WS端点请求?
例如,如果Web服务正在Tomcat(端口8080)上运行,并且我们正在使用mod_proxy在我们的Web页面服务调用中redirect来自端口80上的Web页面的Apache请求 – > tomcat:8080 / webservice。
<Location /admin/tools> Order Deny,Allow Deny from all Allow from localhost Allow from 127.0.0.1 Allow from *local.domain.com </Location> ProxyPass /admin/tools http://localhost:8080/admin/tools ProxyPassReverse /admin/tools http://localhost:8080/admin/tools
当我尝试这样做时,它会locking整个WS端点访问,包括进入代理端点的网页请求。