Restrict Access to Tomcat by Specific IP

Tomcat provides options to allow or restrict access from specific IP addresses.

Add or change the following content between <Host> and </Host> in Tomcat’s configuration file, conf/server.xml, then restart Tomcat.

Allow Access from Specific IP Addresses

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

Deny Access from Specific IP Addresses

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

References