Monday, January 21, 2008

Proxy through to Fisheye from Tomcat 5+

About


If you are using Tomcat 5+ as your primary web server (with APR this is actually feasible), you may wonder how you can proxy through to FishEye.
Out of the box this isn't possible, so here is a small How-To that seems to work properly using j2ep.
This setup may also work using other J2EE web container frontends. It has been verified to work for a setup with Tomcat 5.5.25 and Fisheye 1.4.2.

Note: This setup may not be suitable for large scale installations or sites with a high volume of traffic.

Preparing j2ep


The jEasy Extensible Proxy (j2ep) is a reverse proxy running in tomcat or any other J2EE container.
The setup presented here is supposed to proxy only fisheye, but I think it should be possible to use an adapted ROOT context configuration.

1. Grab the 1.0 release from SourceForge
2. Unpack it and deploy the WAR as "fisheye.war" in your TOMCAT_HOME/webapps
The idea is that the context fisheye will be used for the proxying.
3. Configure TOMCAT_HOME/webapps/fisheye/WEB-INf/web.xml for rewriting:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>j2ep</display-name>
<description>
A J2EE application implementing a reverse proxy.
</description>

<filter>
<filter-name>Rewriter</filter-name>
<filter-class>net.sf.j2ep.RewriteFilter</filter-class>
<init-param>
<param-name>dataUrl</param-name>
<param-value>/WEB-INF/config/data.xml</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>Rewriter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>Proxy</filter-name>
<filter-class>net.sf.j2ep.ProxyFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>Proxy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

4. Configure TOMCAT_HOME/webapps/fisheye/WEB-INf/config/data.xml to:

<?xml version="1.0" encoding="UTF-8"?>
<config>
<server className="net.sf.j2ep.servers.BaseServer"
domainName="yourdomain.com:8060"
path="/fisheye"
isRewriting="true">
<rule className="net.sf.j2ep.rules.AcceptEverythingRule"/>
</server>
</config>


Configuring Fisheye


You need to configure Fisheye as described here. Especifically:
1. Enter the Fisheye admin console
2. Goto Global Settings > Server Settings
3. Configure:
a) Web context: fisheye
b) Proxy host: your proxy address:yourdomain.com
c) Proxy port: your proxy port
4) You will need to restart Fisheye for changes to take effect.

You may alternatively configure through editing your config.xml:

<web-server site-url="http://yourdomain.com/" context="fisheye">
<http bind=":8060" proxy-port="80" proxy-host="yourdomain.com"/>
</web-server>


Test your setup


All that is left to be done is to visit fisheye through your reverse proxied setup and enjoy Fisheye :)