Skip to main content

Tomcat + Apache HTTP: Servers Connecting Guide

Apache Tomcat is a Servlet/JSP container and used to deploy dynamic Java contents like JSPs and Servlets. Tomcat has some web server capabilities, however it is not a full blown web server to serve high traffic web sites. In the meantime Apache HTTP server is a full blown web server. So in general Tomcat is configured along with Apache HTTP server to maintain a healthy web site with dynamic content. This article will cover the steps of configuring HTTP server and Tomcat connection, however this will not discuss installation details of Apache or Tomcat.

System Requirements

  • Apache HTTP server installed
    • download from here
    • we used version 2.2.10 for this article
  • Apache Tomcat installed
    • download from here
    • we used version 5.5 here
Short Names
Followings are the short names used to denote folders used in this article.
    • denotes Apache HTTP Server installation directory. In our testing machine, it is "D:\ASF\Apache"
    • Tomcat installation directory; for example: "D:\ASF\Tomcat"

Connection Configurations

The connection between HTTP server and Tomcat will be done using Apache Tomcat Connector module named mod_jk which is configured inside Apache HTTP server. For that first download the correct version of connector from here.

For version 2.2.10 of Apache HTTP; correct connector version is 2.2.4 (available here). Make sure to download the correct version, as incorrect version may result in errors.

Mod_jk configuration

Apache HTTP ServerNow the downloaded mod_jk module must be configured in Apache HTTP server. First rename the above downloaded file say to "". In Apache server, module files are stored under %APACHE_HTTP_HOME%\modules folder. Now copy the file into this folder.

Then open the HTTP server configuration file named httpd.conf. It's located in %APACHE_HTTP_HOME%\conf folder. This file has a number of lines used to load Modules starting with "LoadModule ". Add the following line below these lines.

LoadModule jk_module modules/

Now the downloaded mod_jk module is added into Apache server.

Tomcat Server Information

We need a new properties file to store details about the Tomcat server. Create a new file named inside %APACHE_HTTP_HOME%\conf folder with the following content.


Pay attention to the above port 8009; this is the port defined inside %CATALINA_HOME%\conf\server.xml file as follows.

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Tomcat ServerIf the port in AJP 1.3 connector section of Tomcat is different than 8009, change the above file to match that.

Now we need to configure the file in %APACHE_HTTP_HOME%\conf\httpd.conf file. For that add the following lines after the line that we added into httpd.conf in a previous step.

JkWorkersFile conf/
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log

Now everything is setup. However still we have not yet defined the important part; which user requests to be forwarded to Tomcat server from Apache server.

URL Patterns

Following is the format of those configurations.

  • <URL_PATTERN> - the url pattern that you need to forward to Tomcat
  • <WORKER> - the worker name defined in file.
We can set up multiple url patterns as follows.

JkMount  /myProject/* localTomcat
JkMount /*.jsp localTomcat
JkMount /*.do localTomcat

First one will send all requests for a web application named "myProject" to Tomcat while the second will send all requests ending with ".jsp". The third line configures for all requests ending with ".do" (many use .do extension with Struts actions).

Add required configuration lines as above into httpd.conf (just after the lines we added in above steps).

Setup Completed

Now try the URLs of your application as follows (using Apache port number, rather than Tomcat port number). We assumed Apache HTTP server is running on port 80. Following as some sample urls for the above configurations.


Now Apache will direct all these request to Tomcat (running on a different port) and serve the client smoothly.

Related Article: How to change Tomcat port

Related Article


  1. Thanks a lot, I setup it, works fine.

  2. This document is really great...Simple and clear


Post a Comment

We appreciate your opinions, suggestions and criticism.

Popular posts from this blog

Web Services with Apache Axis 1.4 Tutorial: server and client sides

Java Sorting: Comparator vs Comparable Tutorial

Creative Commons License Digizol by Kamal Mettananda is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License .
URL of this page must be supplied in attribution
© 2004-2017