The Apache 2.2 webserver has a module for proxiing AJP requests (mod_proxy_ajp). This module is delivered with the Apache webserver by default.
Activating modules
The following modules must be enabled to use the AJP proxy functionallity:
- mod_proxy
- mod_proxy_ajp
- mod_proxy_balancer
To activate the modules uncomment the following lines in your httpd.conf configuration file (e.g. /opt/apache/conf/httpd.conf):
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
Configuring modules
To configure the modules we create a new configuration file conf/ajp_proxy.conf in the apache directory and add the following line to our httpd.conf file:
Include conf/ajp_proxy.conf
First of all we put all configuration directives in
# configuration of AJP proxy
Creating Load Balancer Cluster
The load balancer cluster is created with the ProxyPass directive. The syntax for this directive is
ProxyPassbalancer://
The
Example:
ProxyPass /myapp balancer://mycluster/myapp stickysession=JSESSIONID nofailover=On
In the next step we must define the workers for our cluster and your application server must support the JServ AJP protocol, e.g. Tomcat. For glassfish aka Sun Java System Application Server see my mod_jk tutorial for implementing the JServ protocol into the server.
The workers are definded into a
BalancerMember ajp: :
You can define multiple workers in one proxy directive.
Example for two worker nodes:
BalancerMember ajp://node1.mydomain.com:8009 route=node1 BalancerMember ajp://node2.mydomain.com:8009 route=node2