限制对特定 URL 的访问 (Apache Tomcat) [英] Restrict access to specific URL (Apache Tomcat)

查看:63
本文介绍了限制对特定 URL 的访问 (Apache Tomcat)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何限制对特定 URL(它是 Tomcat 应用程序服务器)的访问?例如http://localhost:8081/application 不能被指定IP以外的用户访问(即调用服务)

How can I restrict access to a specific URL (it is a Tomcat Application Server)? e.g. http://localhost:8081/application cannot be accessed by an user except a specified IP (that is the calling service)

推荐答案

引用:

远程地址过滤器 org.apache.catalina.valves.RemoteAddrValve 允许您将请求客户端的 IP 地址与一个或多个正则表达式进行比较,以根据此结果允许或阻止请求继续比较.远程地址过滤器可以与 Tomcat 引擎、主机或上下文容器相关联.org.apache.catalina.valves.RemoteAddrValve.

The Remote Address filter, org.apache.catalina.valves.RemoteAddrValve, allows you to compare the IP address of the requesting client against one or more regular expressions to either allow or prevent the request from continuing based on the results of this comparison. A Remote Address filter can be associated with a Tomcat Engine, Host, or Context container. org.apache.catalina.valves.RemoteAddrValve.

http://www.oxxus.net/tutorials/tomcat/tomcat-Valve.htm

所以,你需要一些类似

So, you'd need something along the lines of

<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="<your-ip-here>"/>

有关可能的值,请参阅

http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Remote_Address_Filter

您应该能够在您的应用程序的 WEB-INF/web.xml 中设置它,请参阅

You should be able to set this in the WEB-INF/web.xml for your application, see

http://oreilly.com/java/archive/tomcat.html

这篇关于限制对特定 URL 的访问 (Apache Tomcat)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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