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.

test1.abc.com --> HTTPD test1 VirtualHost --> CF Test1
test2.abc.com --> HTTPD test2 VirtualHost --> CF Test2
test3.abc.com --> 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?

See http://tomcat.apache.org/connectors-doc/reference/apache.html

quote

JkWorkersFile   

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.
[...]

unquote

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> section.

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/mod_jk.so
It is probably ignored when it occurs in a VirtualHost section.
See http://httpd.apache.org/docs/2.2/mod/mod_so.html#loadmodule

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 192.168.253.61:80 <http://192.168.253.61/>>
       DocumentRoot /web/app1.dev5.abc.com/scms
       ServerName app1.dev5.abc.com
       ServerAlias origin-app1.dev5.abc.com
       alias /shared-static /web/app1.dev5.abc.com/shared-static
       ErrorLog "|/apps/httpd/bin/rotatelogs
/weblogs/app1.dev5.abc-error.%Y%m%d 86400 -480"
       CustomLog "|/apps/httpd/bin/rotatelogs
/weblogs/app1.dev5.abc-access.%Y%m%d 86400 -480" combined env=!keepaliveuri
       DirectoryIndex index.cfm index.html index.html.var
      #AddDefaultCharset UTF-8

LoadModule jk_module  /apps/httpd/modules/mod_jk.so

        <IfModule mod_jk.c>
         JkMount / cfusion
         JkMount /* cfusion
# Where to find workers.properties
         JkWorkersFile /apps/httpd/conf.d/modjk/app1.dev5.workers.properties
         JkMountFile
/apps/httpd/conf.d/modjk/app1.dev5.uriworkermap.properties
# Where to put jk logs
         JkLogFile /weblogs/mod_jk.app1.dev5.log
# custom environment variables
         JkEnvVar REDIRECT_URL
         JkEnvVar REDIRECT_REMOTE_HOST
         JkEnvVar REDIRECT_PATH
         JkEnvVar REDIRECT_QUERY_STRING
         JkEnvVar REDIRECT_HTTP_ACCEPT
         JkEnvVar REDIRECT_HTTP_USER_AGENT
         JkEnvVar REDIRECT_REMOTE_ADDR
         JkEnvVar REDIRECT_SERVER_NAME
         JkEnvVar REDIRECT_SERVER_PORT
         JkEnvVar REDIRECT_SERVER_SOFTWARE
# 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: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to