Proxy for Tomcat

{quote} 1 This snip requires cleanup {quote}

1 Overview
----
- Configure Tomcat
- Configure Apache


1 Details
----
1.1 Apache Configuration

- Install the mod_jk.so
- Include the auto or custom mod_jk.conf file
- Configure Tomcat Workers file

1.1.1 Install mo
- Download the JK from http://tomcat.apache.org/connectors-doc/
- Rename to mod_jk.so before putting it in your Apache2/modules directory.


1.1.1 Standard Tomcat uses auto jk

Tomcat auto generates a file, ~~mod_jk.conf-auto~~ that you include from the apache conf. If you are running just one tomcat server, and it is on the same system as apache, simply include a line in your httpd.conf like follows;

{code:none}
Include $TOMCAT_HOME/conf/jk/mod_jk.conf-auto
{code}
\\

1.1.1 Non Standard Tomcat uses custom jk

If you are using a instance not on the same box, or multiple tomcats, you must create a custom mod_jk.conf file. Here is a sample one from a windows host. Save it in ~~conf/extra/mod_jk.conf~~ and include it in your httpd.conf as above

__httpd.conf__
{code:none}
Include conf/extra/mod_jk.conf
{code}

__jk_mod.conf__
{code}
# Load The Module
LoadModule    jk_module  modules/mod_jk.so

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

# Where to find workers.properties
JkWorkersFile conf/extra/workers.properties

# Where to put jk shared memory
JkShmFile logs/mod_jk.shm

# Where to put jk logs
JkLogFile logs/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]"

# Send servlet for context /examples to worker named worker1
#JkMount /examples/servlet/* worker1
JkMount /manager* wlb

# Send JSPs for context /examples to worker named worker1
#JkMount /examples/*.jsp worker1
{code}


1.1.1 Worker configuration

{code:none}
# workers.properties.minimal -
#
# This file provides minimal jk configuration properties needed to
# connect to Tomcat.
#
# The workers that jk should create and work with
#

worker.list=wlb,jkstatus

#
# Defining a worker named ajp13w and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13w.type=ajp13
worker.ajp13w.host=boss6.admsrv.ohio.edu
worker.ajp13w.port=8009

#
# Defining a load balancer
#

worker.wlb.type=lb
worker.wlb.balance_workers=ajp13w

#
# Define status worker
#

worker.jkstatus.type=status
{code}



1.1 Tomcat Configuration




reating your workers.properties file at $TOMCAT_HOME/conf/jk/workers.properties and adding the listener to the Engine element in the server.xml




{code:none}
  ...
  <Engine ...>
    ...
    <Listener className="org.apache.jk.config.ApacheConfig" modJk="/path/to/mod_jk.so" />
    ...
  </Engine>
  ...

{code}

Custom mod_jk conf



1 Other Topics

- Configuring Apache to serve static web application files
- Getting mod_jk linked statically with Apache

1 Links
----

http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html





Comments