UnixServerAdmin

Server Administration & Management

How to configure mod_jk module

Here is the general mod_jk section in httpd.conf — note that it needs to be OUTSIDE of the virtual host sections:

# vi /etc/httpd/conf/httpd.conf

#####################################################################
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
# JkWorkersFile specify the location where mod_jk will find the workers definitions.
JkWorkersFile /etc/httpd/conf/workers.properties

# Where to put jk logs
# JkLogFile specify the location where mod_jk is going to place its log file.
# JkLogLevel set the log level between :
JkLogFile /var/log/httpd/mod_jk.log

# Set the jk log level [debug/error/info]
# info log will contains standard mod_jk activity (default).
# error log will contains also error reports.
# debug log will contains all informations on mod_jk activity
JkLogLevel info

# Select the log format
# JkLogStampFormat will configure the date/time format found on mod_jk logfile. Using the strftime()
# format string it’s set by default to “[%a %b %d %H:%M:%S %Y]”
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “

# JkOptions indicate to send SSL KEY SIZE,
# The directive JkOptions allow you to set many forwarding options which will enable (+) or disable (-)
# following option. JkOptions ForwardKeySize , 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).
#
# JkOptions ForwardURICompat , 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).
#
# JkOptions ForwardURICompatUnparsed , the forwarded URI is unparsed, it’s spec compliant but broke mod_rewrite.
#
# JkOptions ForwardURIEscaped , the forwarded URI is escaped and Tomcat (since 3.3 rc2) will do the decoding part.
#
# JkOptions ForwardDirectories is used in conjunction with DirectoryIndex directive of Apache web server.
# As such mod_dir should be available to Apache, statically or dynamically (DSO)
#
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
# JkRequestLogFormat 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 similiar to the Apache LogFormat command, here is a list of the available
# request log format options:
#
#     Options     Description
#     %b         Bytes sent, excluding HTTP headers (CLF format)
#     %B         Bytes sent, excluding HTTP headers
#     %H         The request protocol
#     %m         The request method
#     %p         The canonical Port of the server serving the request
#     %q         The query string (prepended with a ? if a query string exists, otherwise an empty string)
#     %r         First line of request
#     %s         Request HTTP status code
#     %T         Request duration, elapsed time to handle request in seconds ‘.’ micro seconds
#     %U         The URL path requested, not including any query string.
#     %v         The canonical ServerName of the server serving the request
#     %V         The server name according to the UseCanonicalName setting
#     %w         Tomcat worker name
JkRequestLogFormat “%w %V %T”

# The directive JkEnvVar allow you to forward an environment vars from Apache server to Tomcat engine.
JkEnvVar SSL_CLIENT_V_START

# 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: You can use the JkMount directive at the top level or inside <VirtualHost> sections
# of your httpd.conf file.
# Send servlet for context /examples to worker named worker1
JkMount /examples/servlet/* worker1

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

September 20, 2011 Posted by | Java, Tomcat | , , , , | 1 Comment