Using Jetty with an Apache mod_proxy load balancer

by Wolfram Saringer  (2009-04-30)
last change: 2009-04-30

How to force Jetty to use a host identifier in its session cookie values to enable Apache mod_proxy load balancing.

When using Apaches mod_proxy module for load balancing (the preferred method according to the Jetty documentation), the value of the session cookies has to contain the name used in the Apache load balancer configuration.
Create an additional configuration file with the content given below in Jettys etc/ directory and add its name to the startup command line. Change the value HOSTIDENTIFIER to match your Apache load balancer configuration (the value 'route' in the definition of the load balancer cluster)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Get name="sessionHandler">
<Get name="sessionManager">
<Call name="setIdManager">
<New class="org.mortbay.jetty.servlet.HashSessionIdManager">
<Set name="WorkerName">HOSTIDENTIFIER</Set>

all articles represent the sole opinion of their respective author. all content comes without any warranty for correctnes, despite due diligence.