If you have created a custom or local version of mod_jk.conf-local as noted above,
you can change settings such as the workers or URL prefix.
JkMount directive assign specific URLs to Tomcat.
In general the structure of a JkMount directive is:
JkMount [URL prefix] [Worker name]
# send all requests ending in .jsp to worker1
JkMount /*.jsp worker1
# send all requests ending /servlet to worker1
JkMount /*/servlet/ worker1
# send all requests jsp requests to files located in /otherworker will go worker2
JkMount /otherworker/*.jsp worker2
You can use the JkMount directive at the top level or inside <VirtualHost>
sections of your httpd.conf file.
JkUnmount directive acts as an opposite to JkMount and blocks access
to a particular URL. The purpose is to be able to filter out the particular content
types from mounted context. The following example mounts /servlet/*
context, but all .jpg files that belongs to that context are not served.
# send all requests ending with /servlet to worker1
JkMount /servlet/* worker1
# do not send requests ending with .gif to worker1
JkUnMount /servlet/*.gif worker1
JkUnMount takes precedence over JkMount directives, meaning that the JK
will first look for unmount and then for mount directives. The following
example will block all .gif files.
# do not send requests ending with .gif to worker1
JkUnMount /*.gif worker1
# The .gif files will not be mounted cause JkUnMount takes
# precedence over JkMount directive
JkMount /servlet/*.gif worker1
JkAutoAlias directive automatically Alias webapp context directories into
the Apache document space. It enables Apache to serve a static context while Tomcat
serving dynamic context. This directive is used for convenience so that you don't
have to put an apache Alias directive for each application directory inside Tomcat's
webapp directory.
# enter the full path to the tomcat webapps directory
JkAutoAlias /opt/tomtact/webapps
The following example shows how to serve a dynamic context by
Tomcat and static using Apache. The webapps directory has to
be accessible by apache.
# enter the full path to the tomcat webapps directory
JkAutoAlias /opt/tomtact/webapps
# Mount 'servlets-examples' directory. It's physical location
# is assumed to be in the /opt/tomtact/webapps/servlets-examples
# ajp13w is a worker defined in the workers.properties
JkMount /servlets-examples/* ajp13w
# Unmount desired static content from servlets-examples webapp.
# This content will be served by the httpd directly.
JkUnMount /servlets-examples/*.gif ajp13w
JkUnMount /servlets-examples/*.jpg ajp13w
Note that you can have a single JkAutoAlias directive per virtual
host inside your httpd.conf
JkWorkerProperty is a new directive available from JK 1.2.7
version. It is a convenient method for setting directives that are
usually set inside workers.propetiesfile. The parameter for
that directive is raw line from workers.properties file.
# Just like workers.properties but exact line is prefixed
# with JkWorkerProperty
# Minimal jk configuration
JkWorkerProperty worker.list=ajp13w
JkWorkerProperty worker.ajp13w.type=ajp13
JkWorkerProperty worker.ajp13w.host=localhost
JkWorkerProperty worker.ajp13w.port=8009
JkMountFile is a new directive available from JK 1.2.9
version. It is used for dynamic updates of mount points at runtime.
When the mount file is changed, JK will reload it's content.
# Load mount points
JkMountFile conf/uriworkermap.properties
If mount point uri starts with minus '-' char the mount point
will be disabled.
# Sample uriworkermap.properties file
/servlets-examples/*=ajp13w
# Do not map .jpeg files
!/servlets-examples/*.jpeg=ajp13w
# Make jsp examples initially disabled
-/jsp-examples/*=ajp13w
At run time you can change the content of this file. For example
removing minus char will enable the uri mapping. You can add any
number of new entries at runtime that reflects the newly deployed
applications. Apache will reload the file and update the mount
points within 60 second interval.