tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <>
Subject Re: Hosted environment
Date Thu, 22 Dec 2011 19:00:36 GMT
----- Original Message -----

> From: Pid <>
> To: Tomcat Users List <>
> Cc: 
> Sent: Thursday, December 22, 2011 5:25 AM
> Subject: Re: Hosted environment
> In case you prefer the gospel according to the erudite Mr Eggers...
> On 21/12/2011 15:24, Mark Eggers wrote:
>>  Well, you sort of kind of followed that.
>>  Now, as Pid has also pointed out, you will need to configure mod_proxy, 
> mod_proxy_ajp, or mod_ajp to connect Apache HTTPD and Tomcat.
>>  There is a lot of information about how to configure mod_proxy_ajp on the 
> list, as well as a nice sample configuration file in recent source releases of 
> the Tomcat connectors (see the following download page - 
> Once you unpack the download, 
> an example can be found in the conf directory.
>>  There are a couple of reasons to run Apache HTTPD <--> AJP 
> <---> Tomcat. For example; if you don't want to run Tomcat on port 80, 
> if you serve other content (like PHP), or if you have Apache HTTPD modules that 
> provide functionality that Tomcat does not (some authentication modules). If you 
> don't have these types of requirements, then it's much easier to run 
> Tomcat by itself on port 80 and be done with it.
> As above, you will need to configure mod_jk or mod_proxy and
> mod_proxy_ajp or mod_proxy_http.
> p

Sigh, it's not the gospel according to <epithet> Mr. Eggers :-p. I just read and follow
instructions / source code / information on the 'net / snappy answers to my not so bright
questions. Once I figure it all out (TM), I'll write it up and post on a Wiki somewhere.

Here's how I understand things to work. Corrections happily accepted.

Browser <-- HTTP --> Apache HTTPD <-- (assume) AJP --> Tomcat

1. A browser requests a URL and it ends up on the Apache HTTPD server (DNS, etc.)
2. Apache HTTPD does this:
   a. Do I have NamedVirtualHost configured?
   b. Do I have a ServerName or ServerAlias match?
      1. If I match, route to the appropriate virtual host
      2. If I don't match, serve from my default configuration
   c. In the virtual host
      1. Is there a matching JkMount - send it off to Tomcat
      2. If there is no matching JkMount - process locally
3. In Tomcat

   a. Do I have a matching <Host> or <Alias> entry in server.conf
      1. If so, send the request to that
      2. If not, send the request to the default host (by default localhost)
   b. Process the request
   c. Send the results back via AJP to Apache HTTPD
4. In Apache HTTPD
   a. Accept AJP stream from Tomcat
   b. Send back to browser as HTTP

In short, you need to make sure you have a match between the named virtual host in Apache
HTTPD's httpd.conf and the virtual host in Tomcat's server.xml. Match a server alias in Apache
HTTPD's httpd.conf with an alias element in Tomcat's server.xml.

You can actually play games with wild card matches, but then cookie paths might become confusing.
There was a discussion about this on the mailing list a while ago.

As for external access, you'll have to register each domain name so that DNS resolves to the
correct IP address.

. . . . just my two cents.

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

View raw message