JBoss and Tomcat’s servlet container provide a built-in filter that can be used to configure IP Address Filtering. The org.apache.catalina.filters.RemoteAddrFilter
can be configured in the web.xml
file of any application to which you want to restrict access. The filter configuration allows you to specify initial parameters that allow or deny a set of IP addresses or a range of IP addresses represented by regex
patterns.
For example:
<filter> <filter-name>Remote Address Filter</filter-name> <filter-class>org.apache.catalina.filters.RemoteAddrFilter</filter-class> <init-param> <param-name>deny</param-name> <param-value>127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1</param-value> </init-param> </filter> <filter-mapping> <filter-name>Remote Address Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
For detailed information on the RemoteAddrFilter
, refer to the RemoteAddrFilter API documentation on the http://tomcat.apache.org Web site.