Configuring Apache

If you plan to access JOnAS from a Java client without going through a Web server and a JSP/Servlet server, you can skip this section and directly jump to the section called Configuring JOnAS.

Setting up your httpd.conf

Once you have tuned your httpd.conf as described in Apache documentation to suit your configuration, you will just have to append a line at the end of this file. Tomcat provides an auto-configuration file for Apache that is regenerated each time Tomcat is started.

For example, if Tomcat has been installed in the /opt/jakarta-tomcat-3.2.4/ directory, you will have to add Include /opt/jakarta-tomcat-3.2.4/conf/mod_jk.conf-auto.

Specifying a remote or multiple Tomcat servers

The default configuration files provided with Tomcat are designed to run Apache and Tomcat on the same machine. If you want to run one or multiple Tomcat on separate machines, you have to tell Apache where are located those Tomcat servers. All these information are located in the ${TOMCAT_HOME}/conf/workers.properties file. If your TOMCAT_HOME environment variable is not set or you don't know how to set it, refer to the section called Configuring Tomcat.

Apache and Tomcat use a specific protocol to communicate with each other. It is usually AJP12 unless you use secure connections with SSL in which case the AJP13 protocol is used. You will have to specify which protocol you want to use for each Tomcat server. You can also do load balancing between the different instances of Tomcat using a static weight for each of them.

Here is an example of a workers.properties file for 2 Tomcat servers. One is running on a node called node1.rice.edu using the AJP12 protocol and the other one is running on a node named node2.rice.edu using AJP13.

# Tomcat server 1 on node1 uses the AJP12 protocol
worker.tomcat1.port=8007
worker.tomcat1.host=node1.rice.edu
worker.tomcat1.type=ajp12
worker.tomcat1.lbfactor=1

# Tomcat server 2 on node2 uses the AJP13 protocol
worker.tomcat2.port=8009
worker.tomcat2.host=node2.rice.edu
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1

# Load balancer definition
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1, tomcat2

Additional information about the workers.properties file can be found in the file itself or in Tomcat documentation.