Whitelist IP addresses from Tomcat valve’s remote address filter

The remote address filter, org.apache.catalina.valves.RemoteAddrValve let you compare IP address of the requesting client against one or more IP addresses specified in the valve configuration to either allow or prevent the request to get the web resource. Here is an example of using tomcat valve with remote address filter to whitelist 3 IP addresses so that only these requests coming from these 3 IP addresses are allowed to access the web applcation hosted on tomcat. This is a solr search engine on tomcat6, in the context in the file, /etc/tomcat6/Catalina/locathost/solr.xml

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/example/webapps/solr.war" debug="0" crossContext="true">
    <Environment name="solr/home" type="java.lang.String" value="/opt/solr/example/solr" override="true"/>
	<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1,123.4.5.67,8.910.11.12"/>
</Context>

Search within Codexpedia

Custom Search

Search the entire web

Custom Search