httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: [users@httpd] Using ajp with tomcat
Date Tue, 09 Dec 2008 09:29:45 GMT
Angelo Chen wrote:
> Hi,
> My purpose is:
>   goes to Apache HTTP server
>	 goes to my tomcat server
> but this goes always to my tomcat server, any idea?
> Thanks
Try inserting this *before* the other VirtualHost below :

  <VirtualHost *:80>
      ServerName localhost
      DocumentRoot .....

> <VirtualHost *:80>
>     ServerName
>     ProxyPass / ajp://localhost:8009/
>     ProxyRequests Off
>     ProxyPassReverse / ajp://localhost:8009/
>     ProxyPreserveHost On
> </VirtualHost>

Short explanation :
The *first* VirtualHost you define, is the *default* host.
It will "catch" all requests that do not specifically match a 
"ServerName" defined in any of the other VirtualHost sections.
As "ServerName" above, I put "localhost", but basically you can use 
anything that does not match the other "ServerName" directives in the 
other VirtualHos sections.

Longer explanation :
Under HTTP 1.1, requests to your server look like this :
GET /url HTTP/1.1

When Apache gets this, it tries to match the name given in the Host: 
header, to one of the "ServerName" directives of the <VirtualHost> 
sections.  It this match succeeds, Apache will serve this request using 
the "personality" (the configuration) of the matching VirtualHost.
If it does not succeed, then Apache will serve the request using the 
"personality" (the configuration) of the first-defined VirtualHost, no 
matter what that one says in its "ServerName" line.
That is why this first-defined VirtualHost is know as "the default host" 
: it will answer anything that Apache doesn't really know what to do 
with, so to speak.

Even longer explanation :
With your original configuration, the single <VirtualHost> section is, 
at the same time, the VH with ServerName "", AND the 
default VirtualHost (because it is the first VH defined).
So, no matter which hostname is used in the request, as long as the 
request ultimately arrives to Apache, it will be served with the 
personality of that VirtualHost.
And, in your configuration of that VirtualHost, you redirect 
/everything/ to Tomcat. So what happens is quite normal.

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message