Configuring Apache HTTP server and Tomcat with mod jk


Steps :

1) Install Apache 2.2 (Installtion Guide),tomcat

2) Download apprppriate mod_jk from

3) The Apache web server is often used in front of an application server to improve performance in high-load environments. Mod_jk allows request forwarding to an application via a protocol called AJP. Configuration of this involves enabling mod_jk in Apache, configuring a AJP connector in your application server, and directing Apache to forward certain paths to the application server via mod_jk.

Mod_jk is sometimes preferred to mod_proxy because AJP is a binary protocol, and because some site administrators are more familiar with it than with mod_proxy..

The configuration below assumes your pravindemo instance is accessible on the same path on the application server and the web server. For example:

Externally accessible (web server) URL
Application server URL (HTTP)

The AJP connection of the application server is set to:

Configuring mod_jk in Apache

The standard distribution of Apache does not include mod_jk. You need to download it from the JK homepage and put the file in your Apache modules directory.

Next, add the following in httpd.conf directly or included from another file:

# Put this after the other LoadModule directives
LoadModule jk_module modules/

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
JkWorkersFile conf/
JkLogFile logs/mod_jk.log
JkLogLevel info

JkMount /pravindemo worker1
JkMount / pravindemo /* worker1


Create a new file called ‘’, and put it in your Apache conf directory. (The path for was one of the configuration settings above.)


Tomcat Configuration

In Tomcat 5, the AJP connector is enabled by default on port 8009. An absolutely minimal Tomcat server.xml is below for comparison. The relevant line is the Connector with port 8009 – make sure this is uncommented in your server.xml.

<Server port="8005" shutdown="SHUTDOWN">
  <Service name="Catalina">

    <!-- Define a HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" />

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

    <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost" appBase="webapps">
        <Context path="/pravindemo" docBase="/opt/webapps/pravindemo"/>
        <Logger className="org.apache.catalina.logger.FileLogger"/>

Points to note:

  • the Connector on port 8009 has protocol of “AJP/1.3”. This is critical.
  • the Context path of the pravindemo  application is “/ pravindemo “. This must match the path used to access pravindemo on the web server.
  • we recommend keeping your application Contexts outside the server.xml in Tomcat 5.x. The above example includes them for demonstration only.

Improving the performance of the mod_jk connector

The most important setting in high-load environments is the number of processor threads used by the Tomcat AJP connector. By default, this is 200, but you should increase it to match Apache’s maxThreads setting (256 by default):

<Connector port="8009" minSpareThreads="5" maxThreads="256" protocol="AJP/1.3" />

All the configuration parameters for the AJP connector are covered in the Tomcat documentation.

Explore posts in the same categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: