我想通过ip地址限制对在tomcat服务器上运行的webapp的访问。 发现,我将不得不使用org.apache.catalina.valves.RemoteAddrValve
,并将其设置在Tomcat context.xml
通过ip限制tomcat访问
但我的tomcat的文件夹中我有它的4:
\conf
\backup
\webapps\host-manager\META-INF
webapps\manager\META-INF
哪里我必须把我的规则?
我想通过ip地址限制对在tomcat服务器上运行的webapp的访问。 发现,我将不得不使用org.apache.catalina.valves.RemoteAddrValve
,并将其设置在Tomcat context.xml
通过ip限制tomcat访问
但我的tomcat的文件夹中我有它的4:
\conf
\backup
\webapps\host-manager\META-INF
webapps\manager\META-INF
哪里我必须把我的规则?
你必须选择context.xml
,如果你想这个限制适用于您的Tomcat运行的所有的webapps是TOMCAT_HOME/conf/
下里面。
选择yourapp/META-INF/context.xml
如果你想保留它只适用于应用程序。 如果Web应用程序打包为WAR,则/META-INF/context.xml
将被复制到$TOMCAT_HOME/conf/[enginename]/[hostname]/
并重命名以匹配应用程序的上下文路径。
webapps\manager\META-INF
=>如果您在此处添加限制,您的tomcat manager
将被限制,即tomcat administration
。
应该YOUR_WEBAPP/META-INF/context.xml的
这里是RemoteAddressFilter
配置可以添加到Valve
%CATALINA_HOME%\conf\server.xml
但是如果你需要通过IP地址过滤,我会建议你使用防火墙来代替。这是它应该做的第一件事
''Valve className =“org.apache.catalina.valves.RemoteHostValve”allow =“127 \ .0 \ .0 \ .1”/>'有这个我甚至不能从部署它的localhost访问我的webapp。哪里不对? – membersound 2012-08-15 20:19:48
你的第一句话应该指向server.xml。 – EJP 2012-08-15 23:00:40