Tomcat 6 IP address restrictions

Solution 1:

If we want to restrict ip adresses irrespective of the context path we should add the following line in server.xml( Engine name)

 <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1"/>

This will deny all the ip adresses except 127.0.0.1

If you want to aloow multiple ip's use the following

<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1,10.10.12.13,10.132.12"/>

And if you want to deny from only one ip and allow all other ip's use the following

 <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="127.0.0.1"/>

For multiple ip's

<Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="127.0.0.1,10.10.12.13,10.132.12"/>

Solution 2:

This SO question solved my problem.