Question: I want to restrict access to certain URLs in my Tomcat webapp. 
Only 3 known IP addresses should be allowed access to URLs that fit a certain pattern.

e.g. `http://example.com:1234/abc/personId`

How can I achieve this?

Answer: 
Use org.apache.catalina.filters.RemoteAddrFilter and map it to the URL you wish to protect. See <http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Remote_Address_Filter> for configuration details.
You can use something like this to block ips and if you are behind proxy:

```
<Context path="/manager" docBase="manager" reloadable="true" privileged="true" >
  <Valve className="org.apache.catalina.valves.RemoteIpValve"/>
  <Valve className="org.apache.catalina.valves.RemoteHostValve" allow="<your IP regex>"/>
</Context>

```