1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
|
<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>
<p>
Here are the all directives supported by Apache:
</p>
<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>
The name of a worker file for the Tomcat servlet containers
</p></td></tr><tr><td valign="center" align="left"><code>JkWorkerProperty</code></td><td valign="center" align="left"><p>
Enables setting workers.properties inside Apache configuration file.
This directive is available in jk1.2.7 version and later.
</p></td></tr><tr><td valign="center" align="left"><code>JkMount</code></td><td valign="center" align="left"><p>
A mount point from a context to a Tomcat worker
</p></td></tr><tr><td valign="center" align="left"><code>JkMountFile</code></td><td valign="center" align="left"><p>
File containing multiple mappings from a context to a Tomcat worker
</p></td></tr><tr><td valign="center" align="left"><code>JkUnMount</code></td><td valign="center" align="left"><p>
A no mount point from a context to a Tomcat worker
This directive is available in jk1.2.7 version and later.
</p></td></tr><tr><td valign="center" align="left"><code>JkMountCopy</code></td><td valign="center" align="left"><p>
Should the base server mounts be copied to the virtual server.
</p></td></tr><tr><td valign="center" align="left"><code>JkLogFile</code></td><td valign="center" align="left"><p>
Full or server relative path to the Tomcat Connector module log file
</p></td></tr><tr><td valign="center" align="left"><code>JkLogLevel</code></td><td valign="center" align="left"><p>
The Tomcat Connector module log level, can be debug, info, warn
error or trace
</p></td></tr><tr><td valign="center" align="left"><code>JkLogStampFormat</code></td><td valign="center" align="left"><p>
The Tomcat Connector module <b>date</b> log format, follow strftime syntax
</p></td></tr><tr><td valign="center" align="left"><code>JkRequestLogFormat</code></td><td valign="center" align="left"><p>
Request log format string. See detailed description below.
</p></td></tr><tr><td valign="center" align="left"><code>JkAutoAlias</code></td><td valign="center" align="left"><p>
Automatically Alias webapp context directories into the Apache
document space.
</p></td></tr><tr><td valign="center" align="left"><code>JkHTTPSIndicator</code></td><td valign="center" align="left"><p>
Name of the Apache environment variable that contains SSL indication
</p></td></tr><tr><td valign="center" align="left"><code>JkCERTSIndicator</code></td><td valign="center" align="left"><p>
Name of the Apache environment variable that contains SSL client certificates
</p></td></tr><tr><td valign="center" align="left"><code>JkCIPHERIndicator</code></td><td valign="center" align="left"><p>
Name of the Apache environment variable that contains SSL client cipher
</p></td></tr><tr><td valign="center" align="left"><code>JkSESSIONIndicator</code></td><td valign="center" align="left"><p>
Name of the Apache environment variable that contains SSL session
</p></td></tr><tr><td valign="center" align="left"><code>JkKEYSIZEIndicator</code></td><td valign="center" align="left"><p>
Name of the Apache environment variable that contains SSL key size in use
</p></td></tr><tr><td valign="center" align="left"><code>JkExtractSSL</code></td><td valign="center" align="left"><p>
Turns on SSL processing and information gathering by mod_jk
</p></td></tr><tr><td valign="center" align="left"><code>JkOptions</code></td><td valign="center" align="left"><p>
Set one of more options to configure the mod_jk module. See below for
details about this directive
</p></td></tr><tr><td valign="center" align="left"><code>JkEnvVar</code></td><td valign="center" align="left"><p>
Adds a name of environment variable that should be sent to servlet-engine
</p></td></tr><tr><td valign="center" align="left"><code>JkShmFile</code></td><td valign="center" align="left"><p>
Shared memory file name. Used only on unix platforms.
</p></td></tr><tr><td valign="center" align="left"><code>JkShmSize</code></td><td valign="center" align="left"><p>
Size of the shared memory file name. Default is 64 k.
</p></td></tr></table>
</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>
<p>
We'll discuss here the mod_jk directive types.
</p>
<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>
<p>
<b>JkWorkersFile</b> specify the location where mod_jk will find the workers definitions.
Take a look at <a href="workers.html">Workers documentation</a> for detailed description.
<div class="example"><pre>
JkWorkersFile /etc/httpd/conf/workers.properties
</pre></div>
<br>
<br>
</p>
</blockquote></td></tr></table>
<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>
<p>
<b>JkLogFile</b> specify the location where mod_jk is going to place its log file.
</p>
<div class="example"><pre>
JkLogFile /var/log/httpd/mod_jk.log
</pre></div>
<p>
Since JK 1.2.3 for Apache 2.0 and JK 1.2.16 for Apache 1.3 this can also
be used for piped logging:
</p>
<div class="example"><pre>
JkLogFile "|/usr/bin/rotatelogs /var/log/httpd/mod_jk.log 86400"
</pre></div>
<p>
<b>JkLogLevel</b>
set the log level between :
</p>
<ul>
<li>
<b>info</b> log will contain standard mod_jk activity (default).
</li>
<li>
<b>warn</b> log will contain non fatal error reports.
</li>
<li>
<b>error</b> log will contain also error reports.
</li>
<li>
<b>debug</b> log will contain all information on mod_jk activity
</li>
<li>
<b>trace</b> log will contain all tracing information on mod_jk activity
</li>
</ul>
<div class="example"><pre>
JkLogLevel info
</pre></div>
<p>
<b class="code">info</b> should be your default selection for normal operations.
<br>
<br>
</p>
<p>
<b>JkLogStampFormat</b> will configure the date/time format found on mod_jk log file.
Using the strftime() format string it's set by<br>
default to <b>"[%a %b %d %H:%M:%S %Y]"</b>
</p>
<div class="example"><pre>
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
</pre></div>
<p>
<br>
<br>
</p>
<p>
<b>JkRequestLogFormat</b> will configure the format of mod_jk individual request logging.
Request logging is configured and enabled on a per virtual host basis.
To enable request logging for a virtual host just add a JkRequestLogFormat config.
The syntax of the format string is similar to the Apache LogFormat command,
here is a list of the available request log format options:
</p>
<p>
<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>
<div class="example"><pre>
JkRequestLogFormat "%w %V %T"
</pre></div>
<br>
<br>
</p>
</blockquote></td></tr></table>
<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>
<p>
The directive JkOptions allow you to set many forwarding options which will enable (+)
or disable (-) following option.
<br>
<br>
</p>
<p>
JkOptions <b>ForwardKeySize</b>, you ask mod_jk, when using ajp13, to forward also the SSL Key Size as
required by Servlet API 2.3.
This flag shouldn't be set when servlet engine is Tomcat 3.2.x (on by default).
<div class="example"><pre>
JkOptions +ForwardKeySize
</pre></div>
<br>
<br>
</p>
<p>
JkOptions <b>ForwardURICompat</b>, you told mod_jk to send the URI to Tomcat normally,
which is less spec compliant but mod_rewrite compatible,
use it for compatibility with Tomcat 3.2.x engines (on by default).
<div class="example"><pre>
JkOptions +ForwardURICompat
</pre></div>
<br>
<br>
</p>
<p>
JkOptions <b>ForwardURICompatUnparsed</b>, the forwarded URI
is unparsed, it's spec compliant but broke mod_rewrite.
<div class="example"><pre>
JkOptions +ForwardURICompatUnparsed
</pre></div>
<br>
<br>
</p>
<p>
JkOptions <b>ForwardURIEscaped</b>, the forwarded URI is escaped and
Tomcat (since 3.3 rc2) will do the decoding part.
<div class="example"><pre>
JkOptions +ForwardURIEscaped
</pre></div>
<br>
<br>
</p>
<p>
JkOptions <b>ForwardDirectories</b> is used in conjunction with <b>DirectoryIndex</b>
directive of Apache web server. As such mod_dir should be available to Apache,
statically or dynamically (DSO)
<br>
<br>
</p>
<p>
When DirectoryIndex is configured, Apache will create sub-requests for
each of the local-url's specified in the directive, to determine if there is a
local file that matches (this is done by stat-ing the file).
</p>
<p>
If ForwardDirectories is set to false (default) and Apache doesn't find any
files that match, Apache will serve the content of the directory (if directive
Options specifies Indexes for that directory) or a <b class="code">403 Forbidden</b> response (if
directive Options doesn't specify Indexes for that directory).
</p>
<p>
If ForwarDirectories is set to true and Apache doesn't find any files that
match, the request will be forwarded to Tomcat for resolution. This is used in
cases when Apache cannot see the index files on the file system for various
reasons: Tomcat is running on a different machine, the JSP file has been
precompiled etc.
</p>
<p>Note that locally visible files will take precedence over the
ones visible only to Tomcat (i.e. if Apache can see the file, that's the one
that's going to get served). This is important if there is more then one type of
file that Tomcat normally serves - for instance Velocity pages and JSP pages.
<div class="example"><pre>
JkOptions +ForwardDirectories
</pre></div>
<br>
<br>
</p>
<p>
JkOptions <b>ForwardLocalAddress</b>, you told mod_jk to send the local address,
of the Apache web server instead remote client address. This can be used by
Tomcat remote address valve for allowing connections only from registered Apache
web servers.
<div class="example"><pre>
JkOptions +ForwardLocalAddress
</pre></div>
<br>
<br>
</p>
<p>
JkOptions <b>FlushPackets</b>, you told mod_jk to make a flush after each AJP
packet received from Tomcat.
<div class="example"><pre>
JkOptions +FlushPackets
</pre></div>
<br>
<br>
</p>
<p>
The directive <b>JkEnvVar</b> allow you to forward an environment vars from Apache server to Tomcat engine.
<div class="example"><pre>
JkEnvVar SSL_CLIENT_V_START
</pre></div>
<br>
<br>
</p>
</blockquote></td></tr></table>
<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>
<p>
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.
</p>
<p>
<b>JkMount</b> directive assign specific URLs to Tomcat.
In general the structure of a JkMount directive is:
</p>
<div class="example"><pre>
JkMount [URL prefix] [Worker name]
</pre></div>
<div class="example"><pre>
# 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
</pre></div>
<p>
You can use the JkMount directive at the top level or inside <VirtualHost>
sections of your httpd.conf file.
</p>
<p><b>JkUnmount</b> 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 .gif files that belongs to that context are not served.
</p>
<div class="example"><pre>
# send all requests ending with /servlet to worker1
JkMount /servlet/* worker1
# do not send requests ending with .gif to worker1
JkUnMount /servlet/*.gif worker1
</pre></div>
<p>
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.
</p>
<div class="example"><pre>
# 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
</pre></div>
<p>
<b>JkAutoAlias</b> directive automatically <b>Alias</b> 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.
</p>
<div class="example"><pre>
# enter the full path to the tomcat webapps directory
JkAutoAlias /opt/tomtact/webapps
</pre></div>
<p>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.</p>
<div class="example"><pre>
# 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
</pre></div>
<p>Note that you can have a single JkAutoAlias directive per virtual
host inside your httpd.conf
</p>
<p>
<b>JkWorkerProperty</b> is a new directive available from JK 1.2.7
version. It is a convenient method for setting directives that are
usually set inside <b>workers.propeties</b>file. The parameter for
that directive is raw line from workers.properties file.
</p>
<div class="example"><pre>
# 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
</pre></div>
<p>
<b>JkMountFile</b> 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.
</p>
<div class="example"><pre>
# Load mount points
JkMountFile conf/uriworkermap.properties
</pre></div>
<p>If mount point uri starts with minus '-' char the mount point
will be disabled.
</p>
<div class="example"><pre>
# Sample uriworkermap.properties file
/servlets-examples/*=ajp13w
# Do not map .jpeg files
!/servlets-examples/*.jpeg=ajp13w
# Make jsp examples initially disabled
-/jsp-examples/*=ajp13w
</pre></div>
<p>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.
</p>
</blockquote></td></tr></table>
</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>
Copyright © 1999-2005, Apache Software Foundation
</em></font></div></td></tr></table></body></html>
|