Using mod_jk and Jetty
Jetty includes org.mortbay.http.ajp.AJP13Listener, which can be used instead of the normal SocketListener to received requests forwarded from a mod_jk module in apache or IIS.

The AJP13Listener has been tested with mod_jk from apache and mod_jk2 from apache2.

The normal jakarta/apache documentation can be used to configure mod_jk for Jetty. The documentation below was contributed for using mod_jk2 in apache2 and is included with the mod_jk2 source code.


Using mod_jk2 and Jetty

by Simon Stewart<sms@lateral.net>

Jetty is a popular Open Source HTTP Server and Servlet container, written in 100% pure Java. It supports serving static content, servlets and JSPs, and is fast and lightweight. It is commonly used as an embedded HTTP and servlet container, notably by JBoss (a full featured J2EE environment)

Jetty's current developement branch is 4.1. This is working to enhance the performance of the server, as well as to improve its support for apache integration. To further this support, since 4.1.D2 Jetty has shipped with an AJP13 connector, meaning that it can communicate using the mod_jk and mod_jk2 apache modules in addition to working as a standalone server. This document aims to provide a guide for using this facility.

Normal, authenticated and SSL connections are all supported, so in theory, Jetty could be used as a "drop in" replacement for Tomcat.

In order to keep things as simple as possible, this document only considers apache2 and mod_jk2. This is the successor to mod_jk, and uses the same protocol, so using the older module should not cause any problems.

The process will be very similar to installing jk2 on any server, so if you are using IIS or iPlanet, simply follow the normal installation notes for jk2 on those platforms, ignoring any references to compiling the java code. Once the native side of the AJP13 connector is installed, skip to the section on "Configuring Jetty"

Building

Configuring Apache 2

On the native side, jk2 is configured using the workers2.properties file that is kept in apache's conf directory. Currently Jetty's AJP connector supports TCP/IP socket connections.

Perhaps the simplest way to explain things is with an example workers2.properties file:

An "apachectl configtest" should report no errors.

You should configure the URI mappings to cover any installed webapps that you may have. The examples given here are for the demo apps that come with a fresh download of Jetty.

Configuring Jetty

Jetty is easy to configure. At a bare minimum, all that needs to be done is to simply include the following fragment in Jetty's configuration file (typically found at etc/jetty.xml): Once this is place, it should be possible to start Jetty and then (re)start apache. Check that everything works as expected by visiting port 8080 of your server with a web browser. If doesn't work then you have a problem with your Jetty config.

Assuming that you can connect properly to Jetty directly, it's time to connect using jk2. Check that your webserver is running as expected by pointing a browser at the homepage (for example, http://localhost/ ) If this works, attempt to visit one of the mapped URIs.

Congratulations!

Jetty Config Options

The Jetty AJP13 connector has a compact set of configuration options. These are: Most of these default to sensible values, and some of them (such as bufferSize) are unwise to fiddle with. An example of using these config options is given below.
Return to Jetty FAQ.