0

I have a CentOS 5.2 server set up with Apache 2.2.3 and Tomcat 5.5.27. The server hosts multiple virtual hosts connected to multiple Tomcats. For instance we have one tomcat for development and testing and one tomcat for production. project.demo.us.com points to dev tomcat and project.us.com points to production tomcat.

Here's the virtual host's configuration:

<VirtualHost *:80>
    ServerName project.demo.us.com

    CustomLog logs/project.demo.us.com/access_log combined env=!VLOG
    ErrorLog logs/project.demo.us.com/error_log
    DocumentRoot /var/www/vhosts/project.demo.us.com

    <Directory /var/www/vhosts/project.demo.us.com>
            Allow from all
            AllowOverride All
            Options -Indexes FollowSymLinks
    </Directory>

    ##########
    ##########
    ##########

    JkMount /project/* online
</VirtualHost>

JkMount line defines that we use online worker and our workers.properties contains this:

worker.list=..., online, ...

worker.online.port=7703
worker.online.host=localhost
worker.online.type=ajp13
worker.online.lbfactor=1

And tomcat's conf/server.xml contains:

    <Connector port="7703" 
      enableLookups="false" redirectPort="8443" protocol="AJP/1.3" 
      URIEncoding="UTF-8" maxThreads="80"
      minSpareThreads="10" maxSpareThreads="15"/>

I'm not sure what redirectPort is but I tried to telnet to that port and there's no one answering, so it shouldn't matter?

Tomcat's webapps directory contains project.war and the server automatically deployed it under project directory which contains index.jsp and hello.html. The latter is for static debugging purposes.

Now when I try to access http://project.demo.us.com/project/index.jsp, I get Tomcat's HTTP Status 404 - The requested resource () is not available. The same thing happens to hello.html so it's not working with static content either.

Apache's access_log contains:

88.112.152.31 - - [10/Aug/2009:12:15:14 +0300] "GET /demo/index.jsp HTTP/1.1" 404 952 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2"

I couldn't find any mention of the request in Tomcat's logs.

If I shutdown this specific tomcat, I no longer get Tomcat's 404 but Apache's 503 Service Temporarily Unavailable, so I should be configuring the correct Tomcat.

Is there something obvious that I'm missing? Is there any place where I could find out what path the Tomcat is using to look for requested files?

1

3 Answers 3

1

It smells like maybe it's running into a mod_rewrite or alias before it's getting to your virtual host definition. Everything you've posted looks correct, but you can try adding a few extra options:

JkWorkersFile  /explicit/path/to/workers.properties
JkLogFile      /var/log/mod_jk.log
JkLogLevel     debug

That first setting will make sure you're using the actual properties file you think you are, maybe something in your multi-tomcat environment is loading the wrong one. You might also check this specific instance's TOMCAT_HOME to ensure it's loading the right server.xml; you can actually pass that as well as a parameter to $TOMCAT_HOME with -config:

cd $TOMCAT_HOME
./bin/startup.sh -config /direct/path/to/server.xml

See where that takes you...

0

If you increase the logging in the JK module, you should see what the request gets translated to. If you connect directly to Tomcat, and look at the manager, is the target application listed there? If so, does it have the same path that the mapping is using? Does the app work if you use Tomcat's http listener?

1
  • Due to time constraints I had to work around this issue by copying another Tomcat and use it but in the future I'll try these suggestions and report back here. Thank you for the quick response.
    – Thardas
    Aug 10, 2009 at 12:46
0

While not strictly answering your question there is mod_proxy_ajp which could accomplish this for you very quickly and is supported in the vanilla apache version that ships with that version of CentOS

<VirtualHost *:80>
ServerName project.demo.us.com
TransferLog /my/log/dir/access.log
ErrorLog /my/log/dir/error.log
ProxyPass /project ajp://locahost:7703/context/ # Default port is 8009
DocumentRoot /my/doc/root/
<VirtualHost>

<VirtualHost *:80>
ServerName production.demo.us.com
TransferLog /my/log/dir/access.log
ErrorLog /my/log/dir/error.log
ProxyPass /project ajp://locahost:7703/context/ # Default port is 8009
DocumentRoot /my/doc/root/
<VirtualHost>

There are several problems with mod_jk and virtual hosts, one being mounts are generally global. Using mod_proxy_ajp aids in removing these. Its also a hell of a lot easier to maintain.

You must log in to answer this question.