tomcat-users mailing list archives

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

Phil,

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:

/app1/index.jsp
/app2/index.jsp
/app3/index.jsp

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

See
http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#customlog

> 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkn1x8kACgkQ9CaO5/Lv0PBKcACfZNKsAURI7lbVL3wW9VLpG1dc
oekAn17a1fq3yRKs7cLu7qlgP/b4N31i
=gfTd
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message