tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: How do I host multiple websites with Apache2 and Tomcat Cluster ??
Date Mon, 27 Apr 2009 14:57:13 GMT
Hash: SHA1


On 4/26/2009 2:47 AM, nohacks wrote:
> How you host multiple websites with Apache2 and Tomcat Cluster ??

When you say "multiple websites" do you mean "multiple webapps"? Serving
multiple web applications should not be a problem at all:

>         JkMount /*.jsp loadbalancer
>         JkMount /*.jsf loadbalancer

This appears to be a set up for a single webapp, but can certainly be
used to power several sites:


All of these will be sent to Tomcat using the "loadbalancer" worker.
Tomcat will determine which webapp should receive each request.

>         JkMount /servlet/* loadbalancer

Use of the "/servlet" request dispatcher is not recommended. If you have
servlets using this, you might want to consider migrating to a setup
where each servlet is explicitly defined in your web.xml to make a
unique URL. You may already be doing this but have retained the /servlet
prefix for historical reasons. I figured I'm mention it, though.

>         JkMount /* loadbalancer

Technically speaking, this JkMount covers all 3 previous JkMount
statements, so the others are not necessary. But, since you are using
httpd in the first place, why not have it serve your static content for
you? If I were you, I'd remove this JkMount and direct httpd to serve
static files for you, while delegating to Tomcat for things like JSPs
and servlets.

Also, I like to specifically mount each web application separately. I
happen to use different workers for each webapp (I have separate
back-end Tomcats for each one) so I /must/ do this, but it helps
document the httpd configuration file, too:

JkMount /app1/*.jsp loadbalancer
JkMount /app1/*.jsf loadbalancer

JkMount /app2/*.jsp loadbalancer
JkMount /app2/*.jsf loadbalancer

JkMount /app3/*.jsp loadbalancer
JkMount /app3/*.jsf loadbalancer

> It would be nice to have separate log files ??

You can use separate log files within the same VirtualHost section by
using environment variables:

SetEnvIf Request_URI "^/app1/" app1
CustomLog logs/app1.log env=app1


> I am using AJP and wondering how this would work. Also, with sticky sessions
> and separate websites ??

The use of sticky sessions should have no impact on multiple webapps.

- -chris
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message