Configuration

There is only one configuration file you will have to change, which is TOMCAT_HOME/webapps/J2EP_INSTALL_DIR/WEB-INF/data.xml. At default this file looks like this.

<?xml version="1.0" encoding="UTF-8"?> <config> <server className="net.sf.j2ep.servers.BaseServer" domainName="www.nytimes.com" isRewriting="true"> <rule className="net.sf.j2ep.rules.DirectoryRule" directory="/news" /> </server> <server className="net.sf.j2ep.servers.BaseServer" domainName="jakarta.apache.org" isRewriting="true"> <rule className="net.sf.j2ep.rules.AcceptEverythingRule"/> </server> </config>

Structure

As we can see, what is specified is a set of servers used as mappings between the proxy and a webpages. The servers all need to include a rule that is used to match any incoming request. The rules are there to decide what server to use for each request.

Finding a matching server

When the proxy tries to determine where to proxy the request, all the servers' rules are traversed trying to match the current request. In this example there are two servers. When a request comes in it will first try to match the server going to nytimes.com. The rule for this server is a DirectoryRule that will check if the start of the URI matches the directory specified. This means that if we request localhost:8080/news/ this rule will match, but not if we request localhost:8080/somethingelse/

If the request was matched by the first server (to nytimes.com) the request is handled by that server and the rest of the servers are ignored. If the first server didn't match the request the proxy will try to match with the second server and so forth until one server is matched.

Parameters

Both the server and the rule are specified with a className making it possible to create your own rules and servers. Since the parameters will vary based on what server and rule that is used, only a few frequently used parameters are worth mentioning. They are domainName and path and are usually found in all servers, they set the domain and path we want to proxy the requests to.

Information on the parameters and how the matching process works for a particular rule or server are found in the specific documentation found below.

SourceForge.net Logo