-- AditSantokhee - 06 Mar 2008

Introduction

The communication between the Apache HTTP Server and Tomcat can be done via AJP Connectors. By default, both Apache Geronimo distributions (Jetty and Tomcat) have already predefined one AJP v13 Listener, the ports where these listeners are defined varies from one distribution to the other.

 For Jetty the default AJP13 listener port is 8019 
 For Tomcat the default AJP13 listener port is 8009 

The Jakarta Tomcat Connector mod_jk module is provided as a connector from Apache Tomcat source, Jetty (and obviously Tomcat) is fully compatible with this connector. This module is available when you download the Tomcat source, but also is available for download separately, refer to the following URL for the proper version for your system:

In addition to the mod_jk you will require the workers.properties file, also available with the Apache Tomcat source distribution. This properties file tells the mod_jk plugin how to connect to the server. For a detailed explanation on all the available options for configuring the Jakarta Tomcat Connector visit the following URL:

Configure Apache HTTPd

First, make sure you have already installed Tomcat and Apache HTTP. Download the appropriate mod_jk for your platform, rename it to mod_jk.dll (or .so depending on your platform) and copy it into the \modules directory. Download and extract the workers.properties from the Apache Tomcat source (alternatively, download it from the Attachments section) to the \conf directory.

Edit the httpd.conf file located in the \conf directory to load the Jakarta Tomcat Connector mod_jk module. Add the following lines at the end of the httpd.conf file.

# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module /usr/local/apache/modules/mod_jk.so

# Declare the module for <IfModule directive> (remove this line on Apache 2.x)
#AddModule mod_jk.c

# Where to find workers.properties
# Update this path to match your conf directory location 
JkWorkersFile /usr/local/apache/conf/workers.properties

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile     /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel    info

# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# we want users to only access the examples on the tomcat server
# Static files 
Alias /examples "/users/resc/programs/tomcat-webservices-test/webapps/examples"

<Directory "/users/resc/programs/tomcat-webservices-test/webapps/examples">
    Options Indexes FollowSymLinks
    DirectoryIndex index.html index.htm index.jsp 
</Directory>

# Deny direct access to WEB-INF and META-INF
#
<Location "/examples/WEB-INF/*">
    AllowOverride None
    deny from all
</Location>

<Location "/examples/META-INF/*">
    AllowOverride None
    deny from all
</Location>

JkMount /examples/jsp/security/protected/j_security_check  ajp13
JkMount /examples/servlets/servlet/CookieExample  ajp13
JkMount /examples/servlets/servlet/RequestHeaderExample  ajp13
JkMount /examples/*.jsp  ajp13
JkMount /examples/CompressionTest  ajp13
JkMount /examples/servlets/servlet/SessionExample  ajp13
JkMount /examples/servletToJsp  ajp13
JkMount /examples/jsp2/misc/config.jsp  ajp13
JkMount /examples/servlets/servlet/HelloWorldExample  ajp13
JkMount /examples/jsp/chat/chat  ajp13
JkMount /examples/*.jspx  ajp13
JkMount /examples/servlets/servlet/RequestInfoExample/*  ajp13
JkMount /examples/servlets/servlet/RequestParamExample  ajp13
 

  • The rule is that everything should have restricted access, normally a firewall would be placed in between the HTTP and the application server (depending on the topology) and you should map just the minumum resources necessary to have your application working from the other side. You may wish to check this page to do this.

  • There is another way to use mod_jk by modifying server.xml in CATALINA_HOME/conf. This method will provide greater flexibility. (Coming soon)

Configure workers.properties

The workers.properties, among other things, tells the HTTPd where the Tomcat server is, what version of AJP should use and the port where Tomcat is listening.

Edit the workers.properties file located in the \conf directory to match your environment. The following example is an excerpt from the workers.properties file with just the variables you should focus on.

worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
 

Testing

For testing this configuration make sure both Tomcat and HTTPd are up and running.

Links

Topic revision: r4 - 25 Jun 2009 - 12:29:39 - DanBretherton
Resc.FrontingTomcatWithApache moved from ESSCComputing.FrontingTomcatWithApache on 25 Jun 2009 - 12:29 by DanBretherton - put it back
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback