Restrict client IP access

xiaoxiao2021-03-06  41

You may wish...................

Limiting Client Access Using Tomcat (Engine, Host, OR Context Level) If You Want To Limit Client Access AT A High Level Such As The Entire Server, You Will Use A Tomcat Valve.

Tomcat Has Two Valves That Will Filter Traffic Based on The Clinet's IP Address. The RemotehostValve. Both of these Valves Are Extended from RequestFilterValVe.

For a discussion of how to configure tomcat valves see http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/index.html.

To configure Tomcat in jboss, you will need to each.

For JBoss 3.2.4 and higher server.xml is found in / server / /Deploy/jbossweb-tomcat50.sar for jboss 3.2.3 and lower jboss-server.xml is found in / Server / /Deploy/jbossweb-tomcat41.sar/meta-inf

Limiting client access using a servlet filter (Servlet or url-pattern level) If you want to limit client access to a particular servlet or to requests that match a url pattern, you can use the servlet filter attached to this page.

This Requires JDK 1.4 or Higher.

To install, place the attached jar in your WEB-INF / lib directory. If you want to use it in multiple web applications then you can instead put it in your / server / / lib directory.

There is also an attached example show to configure the filter. The main part to look at is the filter definition:

RemotehostFilter

Org.jboss.remotehostfilter.remotehostfilter

deny

150.0.0. *

allow

192.4.5.6, 127.0.0. *

This filter is configured by setting the "allow" and / or "deny" properties to a comma-delimited list of regular expressions (in the syntax supported by the java.util.regex package) to which the client IP address will be compared.

Evaluation Proceeds as Follows:

If there are any deny expressions configured, the IP will be compared to each expression. If a match is found, this request will be rejected with a "Forbidden" HTTP response. If there are any allow expressions configured, the IP will be compared to Each Such Expression. If A Match IS Not Found, this Request Will Be Rejected With A "Forbidden" http response. Otherwise, The Request Will Continue Normal.

ATTACHMENTS:

Hostfilter.jar3771 bytesweb.xml1538 bytesremotehostfilter.java5239 bytestestSERVLET.JAVA2592 BYTES

转载请注明原文地址:https://www.9cbs.com/read-74803.html

New Post(0)