You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/12/09 10:06:28 UTC

[users@httpd] Using ajp with tomcat

Hi,

My purpose is:
http://192.168.1.1   goes to Apache HTTP server
www.myexample.com	 goes to my tomcat server

but this goes always to my tomcat server, any idea?

Thanks

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


-- 
View this message in context: http://www.nabble.com/Using-ajp-with-tomcat-tp20911023p20911023.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Using ajp with tomcat

Posted by Angelo Chen <an...@yahoo.com.hk>.
This works! thanks.

awarnier wrote:
> 
> A
> Try inserting this *before* the other VirtualHost below :
> 
>   <VirtualHost *:80>
>       ServerName localhost
>       DocumentRoot .....
>       ....
>   </VirtualHost>
> 
>>
> 

-- 
View this message in context: http://www.nabble.com/Using-ajp-with-tomcat-tp20911023p20911606.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Using ajp with tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Angelo Chen wrote:
> Hi,
> 
> My purpose is:
> http://192.168.1.1   goes to Apache HTTP server
> www.myexample.com	 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>

> 
> <VirtualHost *:80>
>     ServerName www.myexample.com
>     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
Host: somehost.somecompany.com

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 "www.myexample.com", 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:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org