7.2.2 Using mod_proxy_ajp

This configuration uses Apache mod_proxy_ajp plugin to load balance JBoss cluster on AJP protocol. This module requires the service of mod_proxy . Thus, in order to get the ability of handling AJP protocol, mod_proxy and mod_proxy_ajp should be present in the server.

This module is used to reverse proxy to a backend application server using the AJP protocol. The usage is similar to an HTTP reverse proxy, but uses the ajp:// prefix:

Uncomment the following module configurations in APACHE_HOME/conf/httpd.conf file

LoadModule proxy_module modules/mod_proxy.so 
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so 
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

Add following configuration to the APACHE_HOME/conf/httpd.conf file.

<VirtualHost *:80> 
ServerName lb.xyz.com 
ServerAlias lb.xyz.com 
ProxyRequests Off 
ProxyPreserveHost On 
<Proxy balancer://cluster> 
BalancerMember ajp://abc.com:8009 route=node1 
BalancerMember ajp://xyz.com:8009 route=node2 
ProxySet lbmethod=byrequests 
</Proxy> 
ProxyPass / balancer://cluster/ stickysession=JSESSIONID|jsessionid 
</VirtualHost>

Usually, no ProxyPassReverse directive is necessary. The AJP request includes the original host header given to the proxy, and the application server can be expected to generate self-referential headers relative to this host, so no rewriting is required.

Server-Side Configuration :

  1. For each node in the cluster, open the server.xml file located at [appserver root]/server/<profile_name>/deploy/jbossweb.sar for editing.

  2. Search the server.xml file for the Engine name element and add a jvmRoute attribute. For example, on a node named node1, edit the element to read as follows: <Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">

  3. Save the edited server.xml file.

    Note: For each cluster, the node value of jvmRoute must be unique and match to the value of the route of the worker that connects to the respective JBoss (See BalancerMember Configuration in httpd.conf).

// Ethnio survey code removed