tomcat可以拒绝指定IP访问web应用,具体配置参照如下:
/tomcat/conf/server.xml
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="192.168.246.49"/>
<Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="192.168.246.50"/>
</Host>
上述配置限制了IP192.168.246.49和192.168.246.50对该web应用的访问。