tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: Configuring mod_jk with multiple Apache HTTPD Virtual Hosts
Date Mon, 03 Mar 2014 21:57:13 GMT
Doug Strick wrote:
> Hello,
> I'm currently working on a project where we're migrating from Adobe
> Coldfusion 8 to CF 10.  Adobe CF10 now uses tomcat as the underlying server
> and mod_jk is the standard connector used.  On our test environment we have
> a single apache httpd instance serving multiple domains with each going to
> a different CF instance.  We really only want specific workers enabled for
> specific virtual hosts like below.
> --> HTTPD test1 VirtualHost --> CF Test1
> --> HTTPD test2 VirtualHost --> CF Test2
> --> HTTPD test3 VirtualHost --> CF Test3
> Each CF instance is on a separate host. A developer has managed to get a
> config working on their local desktop where CF10 runs under windows and
> apache runs under a linux VM.  The real dev environment is a lot more
> complicated with multiple virtual hosts.  CF is the only one where we're
> going to use mod_jk (CF 8 used mod_jrun22) so this is the first time using
> mod_jk in our environment.  Using the below config I keep getting
> "JkWorkersFile cannot occur within <VirtualHost> section".  Does anyone
> have any suggestions as to what I need to do to make this work?  




The name of a worker file for the Tomcat servlet containers.
This directive is only allowed once. It must be put into the global part of the configuration.


And the same for the "JkShmFile" directive.

The "global part of the configuration" refers to the main (or default) Apache httpd 
configuration file (apache2.conf or httpd.conf e.g.), *outside* of any <VirtualHost>

The "JkWorkersFile" file defines *all* the "workers" (in mod_jk parlance, a "worker" is 
usually "one back-end Tomcat instance"). So in your case, you would have 3 workers (Test1,

Test2 and Test3).

Then inside of each <VirtualHost> section, you would use "JkMount" directives, to indicate

*for this VirtualHost* which URI's should be proxied to which of the known workers.
For example,
in <VirtualHost #1>
    JkMount /myapp/ Test1
    JkMount /myapp/* Test1

in <VirtualHost #2>
    JkMount /myapp/ Test2
    JkMount /myapp/* Test2

in <VirtualHost #3>
    JkMount /myapp/ Test3
    JkMount /myapp/* Test3

Also, it does not really make much sense to have both "JkMount" directives directly in 
your configuration, *and* a "JkMountFile" directive. Usually, one uses the one or the 
other. It is less confusing, because both specify lists of URI's which should be/should 
not be proxied to Tomcat.

Another configuration directive which should only be there once, and in the main httpd 
configuration section (not in <VirtualHost>) is
 > LoadModule jk_module  /apps/httpd/modules/
It is probably ignored when it occurs in a VirtualHost section.

There are some other things which I find a bit strange (or unclear or redundant) in the 
configuration below, such as  the conjunction of :

 >        DirectoryIndex index.cfm index.html index.html.var
 >          JkMount / cfusion
 >          JkMount /* cfusion
 >          AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
 >          DirectoryIndex index.cfm

All in all, it looks a bit like an accumulation of miscellaneous overlapping and 
contradictory instructions, put together by chance more than by a good understanding of 
what each one really achieves and in what order they are evaluated.
For example :

 >          JkMount / cfusion
 >          JkMount /* cfusion
These directives will result in Apache httpd, in effect, proxying *all* requests to the 
Tomcat worker named "cfusion", leaving none to be handled by Apache httpd itself.
But then, these directives :
 >        DirectoryIndex index.cfm index.html index.html.var
 >          AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
 >          DirectoryIndex index.cfm

are totaly redundant, even among themselves.

This is
> currently apache 2.2.26 compiled from source and mod_jk 1.2.37 compiled
> from source as well.
> --------------------VirtualHost Example--------------------------------
> <VirtualHost <>>
>        DocumentRoot /web/
>        ServerName
>        ServerAlias
>        alias /shared-static /web/
>        ErrorLog "|/apps/httpd/bin/rotatelogs
> /weblogs/ 86400 -480"
>        CustomLog "|/apps/httpd/bin/rotatelogs
> /weblogs/ 86400 -480" combined env=!keepaliveuri
>        DirectoryIndex index.cfm index.html index.html.var
>       #AddDefaultCharset UTF-8
> LoadModule jk_module  /apps/httpd/modules/
>         <IfModule mod_jk.c>
>          JkMount / cfusion
>          JkMount /* cfusion
> # Where to find
>          JkWorkersFile /apps/httpd/conf.d/modjk/
>          JkMountFile
> /apps/httpd/conf.d/modjk/
> # Where to put jk logs
>          JkLogFile /weblogs/mod_jk.app1.dev5.log
> # custom environment variables
>          JkEnvVar REDIRECT_URL
>          JkEnvVar REDIRECT_PATH
> # Where to put jk shared memory
>          JkShmFile /weblogs/app1.dev5.jk_shm
> # Set the jk log level [debug/error/info]
>          JkLogLevel info
> # Select the timestamp log format
>          JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
>          JkOptions +ForwardDirectories
>          AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
>          DirectoryIndex index.cfm
>            <Files ~ ".hbmxml$">
>              Order allow,deny
>              Deny from all
>            </Files>
>         </IfModule>
> </VirtualHost>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message