1
<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Tomcat Connector - Configuring Apache</title><meta value="Mladen Turk" name="author"><meta value="mturk@apache.org" name="email"><link rel="stylesheet" type="text/css" href="../../style.css"></head><body vlink="#525D76" alink="#525D76" link="#525D76" text="#000000" bgcolor="#ffffff"><table cellspacing="4" width="100%" border="0"><!--PAGE HEADER--><tr><td colspan="2"><!--TOMCAT LOGO--><a href="http://tomcat.apache.org/"><img border="0" alt="Apache Tomcat" align="left" src="../../images/tomcat.gif"></a><!--APACHE LOGO--><a href="http://www.apache.org/"><img border="0" alt="Apache Logo" align="right" src="http://www.apache.org/images/asf-logo.gif"></a></td></tr><!--HEADER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade="noshade"></td></tr><tr><!--RIGHT SIDE MAIN BODY--><td align="left" valign="top" width="80%"><table cellspacing="4" width="100%" border="0"><tr><td valign="top" align="left"><h1>Tomcat Connector</h1><h2>Configuring Apache</h2></td><td nowrap="true" valign="top" align="right"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Configuration Directives"><strong>Configuration Directives</strong></a></font></td></tr><tr><td><blockquote>
3
Here are the all directives supported by Apache:
5
<table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="220px"><font color="#ffffff">Directive</font></th><th bgcolor="#023264" width="*"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>JkWorkersFile</code></td><td valign="center" align="left"><p>
6
The name of a worker file for the Tomcat servlet containers
7
</p></td></tr><tr><td valign="center" align="left"><code>JkWorkerProperty</code></td><td valign="center" align="left"><p>
8
Enables setting workers.properties inside Apache configuration file.
9
This directive is available in jk1.2.7 version and later.
10
</p></td></tr><tr><td valign="center" align="left"><code>JkMount</code></td><td valign="center" align="left"><p>
11
A mount point from a context to a Tomcat worker
12
</p></td></tr><tr><td valign="center" align="left"><code>JkMountFile</code></td><td valign="center" align="left"><p>
13
File containing multiple mappings from a context to a Tomcat worker
14
</p></td></tr><tr><td valign="center" align="left"><code>JkUnMount</code></td><td valign="center" align="left"><p>
15
A no mount point from a context to a Tomcat worker
16
This directive is available in jk1.2.7 version and later.
17
</p></td></tr><tr><td valign="center" align="left"><code>JkMountCopy</code></td><td valign="center" align="left"><p>
18
Should the base server mounts be copied to the virtual server.
19
</p></td></tr><tr><td valign="center" align="left"><code>JkLogFile</code></td><td valign="center" align="left"><p>
20
Full or server relative path to the Tomcat Connector module log file
21
</p></td></tr><tr><td valign="center" align="left"><code>JkLogLevel</code></td><td valign="center" align="left"><p>
22
The Tomcat Connector module log level, can be debug, info, warn
24
</p></td></tr><tr><td valign="center" align="left"><code>JkLogStampFormat</code></td><td valign="center" align="left"><p>
25
The Tomcat Connector module <b>date</b> log format, follow strftime syntax
26
</p></td></tr><tr><td valign="center" align="left"><code>JkRequestLogFormat</code></td><td valign="center" align="left"><p>
27
Request log format string. See detailed description below.
28
</p></td></tr><tr><td valign="center" align="left"><code>JkAutoAlias</code></td><td valign="center" align="left"><p>
29
Automatically Alias webapp context directories into the Apache
31
</p></td></tr><tr><td valign="center" align="left"><code>JkHTTPSIndicator</code></td><td valign="center" align="left"><p>
32
Name of the Apache environment variable that contains SSL indication
33
</p></td></tr><tr><td valign="center" align="left"><code>JkCERTSIndicator</code></td><td valign="center" align="left"><p>
34
Name of the Apache environment variable that contains SSL client certificates
35
</p></td></tr><tr><td valign="center" align="left"><code>JkCIPHERIndicator</code></td><td valign="center" align="left"><p>
36
Name of the Apache environment variable that contains SSL client cipher
37
</p></td></tr><tr><td valign="center" align="left"><code>JkSESSIONIndicator</code></td><td valign="center" align="left"><p>
38
Name of the Apache environment variable that contains SSL session
39
</p></td></tr><tr><td valign="center" align="left"><code>JkKEYSIZEIndicator</code></td><td valign="center" align="left"><p>
40
Name of the Apache environment variable that contains SSL key size in use
41
</p></td></tr><tr><td valign="center" align="left"><code>JkExtractSSL</code></td><td valign="center" align="left"><p>
42
Turns on SSL processing and information gathering by mod_jk
43
</p></td></tr><tr><td valign="center" align="left"><code>JkOptions</code></td><td valign="center" align="left"><p>
44
Set one of more options to configure the mod_jk module. See below for
45
details about this directive
46
</p></td></tr><tr><td valign="center" align="left"><code>JkEnvVar</code></td><td valign="center" align="left"><p>
47
Adds a name of environment variable that should be sent to servlet-engine
48
</p></td></tr><tr><td valign="center" align="left"><code>JkShmFile</code></td><td valign="center" align="left"><p>
49
Shared memory file name. Used only on unix platforms.
50
</p></td></tr><tr><td valign="center" align="left"><code>JkShmSize</code></td><td valign="center" align="left"><p>
51
Size of the shared memory file name. Default is 64 k.
52
</p></td></tr></table>
53
</blockquote></td></tr></table><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Configuration Directives Types"><strong>Configuration Directives Types</strong></a></font></td></tr><tr><td><blockquote>
55
We'll discuss here the mod_jk directive types.
58
<table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Define workers"><strong>Define workers</strong></a></font></td></tr><tr><td><blockquote>
60
<b>JkWorkersFile</b> specify the location where mod_jk will find the workers definitions.
61
Take a look at <a href="workers.html">Workers documentation</a> for detailed description.
63
<div class="example"><pre>
65
JkWorkersFile /etc/httpd/conf/workers.properties
71
</blockquote></td></tr></table>
73
<table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Logging"><strong>Logging</strong></a></font></td></tr><tr><td><blockquote>
75
<b>JkLogFile</b> specify the location where mod_jk is going to place its log file.
78
<div class="example"><pre>
79
JkLogFile /var/log/httpd/mod_jk.log
83
Since JK 1.2.3 for Apache 2.0 and JK 1.2.16 for Apache 1.3 this can also
84
be used for piped logging:
87
<div class="example"><pre>
88
JkLogFile "|/usr/bin/rotatelogs /var/log/httpd/mod_jk.log 86400"
93
set the log level between :
98
<b>info</b> log will contain standard mod_jk activity (default).
101
<b>warn</b> log will contain non fatal error reports.
104
<b>error</b> log will contain also error reports.
107
<b>debug</b> log will contain all information on mod_jk activity
110
<b>trace</b> log will contain all tracing information on mod_jk activity
114
<div class="example"><pre>
119
<b class="code">info</b> should be your default selection for normal operations.
125
<b>JkLogStampFormat</b> will configure the date/time format found on mod_jk log file.
126
Using the strftime() format string it's set by<br>
127
default to <b>"[%a %b %d %H:%M:%S %Y]"</b>
130
<div class="example"><pre>
131
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
140
<b>JkRequestLogFormat</b> will configure the format of mod_jk individual request logging.
141
Request logging is configured and enabled on a per virtual host basis.
142
To enable request logging for a virtual host just add a JkRequestLogFormat config.
143
The syntax of the format string is similar to the Apache LogFormat command,
144
here is a list of the available request log format options:
148
<table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="220px"><font color="#ffffff">Options</font></th><th bgcolor="#023264" width="*"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>%b</code></td><td valign="center" align="left">Bytes sent, excluding HTTP headers (CLF format)</td></tr><tr><td valign="center" align="left"><code>%B</code></td><td valign="center" align="left">Bytes sent, excluding HTTP headers</td></tr><tr><td valign="center" align="left"><code>%H</code></td><td valign="center" align="left">The request protocol</td></tr><tr><td valign="center" align="left"><code>%m</code></td><td valign="center" align="left">The request method</td></tr><tr><td valign="center" align="left"><code>%p</code></td><td valign="center" align="left">The canonical Port of the server serving the request</td></tr><tr><td valign="center" align="left"><code>%q</code></td><td valign="center" align="left">The query string (prepended with a ? if a query string exists, otherwise an empty string)</td></tr><tr><td valign="center" align="left"><code>%r</code></td><td valign="center" align="left">First line of request</td></tr><tr><td valign="center" align="left"><code>%s</code></td><td valign="center" align="left">Request HTTP status code</td></tr><tr><td valign="center" align="left"><code>%T</code></td><td valign="center" align="left">Request duration, elapsed time to handle request in seconds '.' micro seconds</td></tr><tr><td valign="center" align="left"><code>%U</code></td><td valign="center" align="left">The URL path requested, not including any query string.</td></tr><tr><td valign="center" align="left"><code>%v</code></td><td valign="center" align="left">The canonical ServerName of the server serving the request</td></tr><tr><td valign="center" align="left"><code>%V</code></td><td valign="center" align="left">The server name according to the UseCanonicalName setting</td></tr><tr><td valign="center" align="left"><code>%w</code></td><td valign="center" align="left">Tomcat worker name</td></tr></table>
150
<div class="example"><pre>
151
JkRequestLogFormat "%w %V %T"
158
</blockquote></td></tr></table>
160
<table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Forwarding"><strong>Forwarding</strong></a></font></td></tr><tr><td><blockquote>
162
The directive JkOptions allow you to set many forwarding options which will enable (+)
163
or disable (-) following option.
169
JkOptions <b>ForwardKeySize</b>, you ask mod_jk, when using ajp13, to forward also the SSL Key Size as
170
required by Servlet API 2.3.
171
This flag shouldn't be set when servlet engine is Tomcat 3.2.x (on by default).
173
<div class="example"><pre>
174
JkOptions +ForwardKeySize
182
JkOptions <b>ForwardURICompat</b>, you told mod_jk to send the URI to Tomcat normally,
183
which is less spec compliant but mod_rewrite compatible,
184
use it for compatibility with Tomcat 3.2.x engines (on by default).
186
<div class="example"><pre>
187
JkOptions +ForwardURICompat
195
JkOptions <b>ForwardURICompatUnparsed</b>, the forwarded URI
196
is unparsed, it's spec compliant but broke mod_rewrite.
198
<div class="example"><pre>
199
JkOptions +ForwardURICompatUnparsed
207
JkOptions <b>ForwardURIEscaped</b>, the forwarded URI is escaped and
208
Tomcat (since 3.3 rc2) will do the decoding part.
210
<div class="example"><pre>
211
JkOptions +ForwardURIEscaped
219
JkOptions <b>ForwardDirectories</b> is used in conjunction with <b>DirectoryIndex</b>
220
directive of Apache web server. As such mod_dir should be available to Apache,
221
statically or dynamically (DSO)
227
When DirectoryIndex is configured, Apache will create sub-requests for
228
each of the local-url's specified in the directive, to determine if there is a
229
local file that matches (this is done by stat-ing the file).
233
If ForwardDirectories is set to false (default) and Apache doesn't find any
234
files that match, Apache will serve the content of the directory (if directive
235
Options specifies Indexes for that directory) or a <b class="code">403 Forbidden</b> response (if
236
directive Options doesn't specify Indexes for that directory).
240
If ForwarDirectories is set to true and Apache doesn't find any files that
241
match, the request will be forwarded to Tomcat for resolution. This is used in
242
cases when Apache cannot see the index files on the file system for various
243
reasons: Tomcat is running on a different machine, the JSP file has been
247
<p>Note that locally visible files will take precedence over the
248
ones visible only to Tomcat (i.e. if Apache can see the file, that's the one
249
that's going to get served). This is important if there is more then one type of
250
file that Tomcat normally serves - for instance Velocity pages and JSP pages.
252
<div class="example"><pre>
253
JkOptions +ForwardDirectories
260
JkOptions <b>ForwardLocalAddress</b>, you told mod_jk to send the local address,
261
of the Apache web server instead remote client address. This can be used by
262
Tomcat remote address valve for allowing connections only from registered Apache
265
<div class="example"><pre>
266
JkOptions +ForwardLocalAddress
274
JkOptions <b>FlushPackets</b>, you told mod_jk to make a flush after each AJP
275
packet received from Tomcat.
277
<div class="example"><pre>
278
JkOptions +FlushPackets
286
The directive <b>JkEnvVar</b> allow you to forward an environment vars from Apache server to Tomcat engine.
288
<div class="example"><pre>
289
JkEnvVar SSL_CLIENT_V_START
295
</blockquote></td></tr></table>
297
<table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Assigning URLs to Tomcat"><strong>Assigning URLs to Tomcat</strong></a></font></td></tr><tr><td><blockquote>
299
If you have created a custom or local version of mod_jk.conf-local as noted above,
300
you can change settings such as the workers or URL prefix.
303
<b>JkMount</b> directive assign specific URLs to Tomcat.
304
In general the structure of a JkMount directive is:
307
<div class="example"><pre>
308
JkMount [URL prefix] [Worker name]
311
<div class="example"><pre>
312
# send all requests ending in .jsp to worker1
313
JkMount /*.jsp worker1
314
# send all requests ending /servlet to worker1
315
JkMount /*/servlet/ worker1
316
# send all requests jsp requests to files located in /otherworker will go worker2
317
JkMount /otherworker/*.jsp worker2
321
You can use the JkMount directive at the top level or inside <VirtualHost>
322
sections of your httpd.conf file.
324
<p><b>JkUnmount</b> directive acts as an opposite to JkMount and blocks access
325
to a particular URL. The purpose is to be able to filter out the particular content
326
types from mounted context. The following example mounts /servlet/*
327
context, but all .gif files that belongs to that context are not served.
329
<div class="example"><pre>
330
# send all requests ending with /servlet to worker1
331
JkMount /servlet/* worker1
332
# do not send requests ending with .gif to worker1
333
JkUnMount /servlet/*.gif worker1
336
JkUnMount takes precedence over JkMount directives, meaning that the JK
337
will first look for unmount and then for mount directives. The following
338
example will block all .gif files.
340
<div class="example"><pre>
341
# do not send requests ending with .gif to worker1
342
JkUnMount /*.gif worker1
343
# The .gif files will not be mounted cause JkUnMount takes
344
# precedence over JkMount directive
345
JkMount /servlet/*.gif worker1
349
<b>JkAutoAlias</b> directive automatically <b>Alias</b> webapp context directories into
350
the Apache document space. It enables Apache to serve a static context while Tomcat
351
serving dynamic context. This directive is used for convenience so that you don't
352
have to put an apache Alias directive for each application directory inside Tomcat's
356
<div class="example"><pre>
357
# enter the full path to the tomcat webapps directory
358
JkAutoAlias /opt/tomtact/webapps
360
<p>The following example shows how to serve a dynamic context by
361
Tomcat and static using Apache. The webapps directory has to
362
be accessible by apache.</p>
364
<div class="example"><pre>
365
# enter the full path to the tomcat webapps directory
366
JkAutoAlias /opt/tomtact/webapps
368
# Mount 'servlets-examples' directory. It's physical location
369
# is assumed to be in the /opt/tomtact/webapps/servlets-examples
370
# ajp13w is a worker defined in the workers.properties
371
JkMount /servlets-examples/* ajp13w
373
# Unmount desired static content from servlets-examples webapp.
374
# This content will be served by the httpd directly.
375
JkUnMount /servlets-examples/*.gif ajp13w
376
JkUnMount /servlets-examples/*.jpg ajp13w
378
<p>Note that you can have a single JkAutoAlias directive per virtual
379
host inside your httpd.conf
382
<b>JkWorkerProperty</b> is a new directive available from JK 1.2.7
383
version. It is a convenient method for setting directives that are
384
usually set inside <b>workers.propeties</b>file. The parameter for
385
that directive is raw line from workers.properties file.
387
<div class="example"><pre>
388
# Just like workers.properties but exact line is prefixed
389
# with JkWorkerProperty
391
# Minimal jk configuration
392
JkWorkerProperty worker.list=ajp13w
393
JkWorkerProperty worker.ajp13w.type=ajp13
394
JkWorkerProperty worker.ajp13w.host=localhost
395
JkWorkerProperty worker.ajp13w.port=8009
398
<b>JkMountFile</b> is a new directive available from JK 1.2.9
399
version. It is used for dynamic updates of mount points at runtime.
400
When the mount file is changed, JK will reload it's content.
402
<div class="example"><pre>
405
JkMountFile conf/uriworkermap.properties
407
<p>If mount point uri starts with minus '-' char the mount point
410
<div class="example"><pre>
411
# Sample uriworkermap.properties file
413
/servlets-examples/*=ajp13w
414
# Do not map .jpeg files
415
!/servlets-examples/*.jpeg=ajp13w
416
# Make jsp examples initially disabled
417
-/jsp-examples/*=ajp13w
419
<p>At run time you can change the content of this file. For example
420
removing minus char will enable the uri mapping. You can add any
421
number of new entries at runtime that reflects the newly deployed
422
applications. Apache will reload the file and update the mount
423
points within 60 second interval.
426
</blockquote></td></tr></table>
427
</blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade="noshade"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font size="-1" color="#525D76"><em>
428
Copyright © 1999-2005, Apache Software Foundation
429
</em></font></div></td></tr></table></body></html>
b'\\ No newline at end of file'