Configuring AJP13 Using mod_jk or mod_proxy_ajp

Support for this feature has been dropped with Jetty 9.If you feel this should be brought back please file a bug.

The Apache web server is frequently used as a server in front of a servlet container. While there are no real technical reasons to front Jetty with Apache, you might choose to do so for software load balancing, to fit with a corporate infrastructure, or simply to stick with a known deployment structure.

The AJP protocol is poorly documented and has many version irregularities.

If you must use AJP, the mod_proxy_ajp module is better than mod_jk. Previously, the load balancing capabilities of mod_jk meant that you had to use (tolerate) it, but with Apache 2.2, mod_proxy_balancer is available and works over HTTP and AJP connectors.

Using HTTP

We recommend this mechanism to connect Apache and Jetty.

To configure Apache to use mod_proxy, mod_proxy_http and/or mod_proxy_balancer with HTTP, see Configuring mod_proxy.

Using AJP

We do NOT recommend AJP. Use HTTP and mod_proxy instead (see above).

We do not recommend AJP for these reasons:

Historically mod_jk has had intermittent maintenance and bad versioning practices. This make it difficult to select a known, good version that is fully compatible with the AJP connector you are running.

The mod_proxy plugin is more actively maintained and the mod_proxy_balancer supports a richer set of options for load balancing.

Jetty is optimized to deal with the text-based HTTP protocol, and the servlet API also exposes the text nature of HTTP to the application. There are no measurable benefits for using Apache to convert text HTTP to the binary AJP protocol, only for Jetty to have to convert back. Some tests have shown 15% more throughput with mod_proxy than with mod_ajp.

With cometd style applications, neither mod_jk nor mod_proxy scale well. However, mod_proxy does make greater use of connections, so it is a better choice for moderate comet load. For full comet scaling, you should either directly expose Jetty to the Internet, or use an async load balancer like Nginx.

Note however that the Jetty team still supports AJP, and we will strive to fix any issues found.

The Jetty AJP Connector

To use AJP with either mod_jk or mod_proxy_ajp, you need to configure Jetty with an AJP13 connector. You can do so by adding etc/jetty-ajp.xml to the command line. You can also modify an existing jetty.xml file with:

mod_proxy_ajp

Compatibility

Apache

Win32

Linux (Ubuntu)

Apache 1.3

no mod_proxy_ajp bundled

no mod_proxy_ajp bundled

Apache 2.0 (2.0.59)

no mod_proxy_ajp bundled

no mod_proxy_ajp bundled

Apache 2.2

Configuration

The configuration of mod_proxy_ajp is identical to the [[JETTY/Howto_Configure_mod_proxy configuration of mod_proxy], except that you can use ajp:// as a protocol instead of http:// when specifying destinations (workers) in ProxyPass and BalancerMember elements.

Apache 2.2 normally bundles mod_proxy, mod_proxy_ajp and mod_proxy_balancer, so often you do not need to install them separately. If they are separately bundled by your operating system (for example, as RPMs or Debians), ensure that they are installed.

The Apache configuration structure can vary greatly with operating system distros, and there might be some template configurations for mod_proxy. If not, add the entry below in your httpd.conf apache configuration file located in <apache-root>/conf/ directory: