How to restrict access by IP address with Tomcat?

Solution 1:

You add a Valve to the Context in context.xml (specifically, org.apache.catalina.valves.RemoteAddrValve). See the docs on Remote Host Filters.

Solution 2:

This is an example:

in \apache-tomcat-7.0.33\conf\server.xml:

<Engine name="Catalina" defaultHost="localhost">
    ...
    ...
    ...
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="10\.132\.77\.55|10\.132\.76\.120|10\.132\.77\.47"/>
    ...
</Engine>