You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by to...@shwango.com on 2002/02/06 07:15:24 UTC

Mapping multiple hosts to single Host

I've read many posts about virtual hosts and Tomcat with and without 
mod_jk/mod_webapp, but haven't found a real answer to my question.  We want to 
map multiple hosts to a single <Host> config in server.xml.  I thought the 
defaultHost setting would do this, but it doesn't work.  If I have DNS entries 
for server1.xyz.com and server2.abc.com that point to the same IP address and 
an Apache virtual host and on to mod_webapp, if I don't define and <Host> 
settings, Tomcat will serve out any web apps in the webapps directory.  The 
problem is that I'd like to run the manager app, but that requires 
privileged="true" which (as far as I know) must be done in a <Host><Context> 
config.  Basically we want to map multiple domains to a webapp and based on 
the "host" value, send a response out.  Kind of along the lines of Apache's 
wildcard host syntax.

Hope the post isn't too confusing.  Any ideas?

-Pat


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Mapping multiple hosts to single Host

Posted by to...@shwango.com.
Correct.  We're currently using the host settings in server.xml which match 
virtual hosts in Apache.  I've done some testing with Apache aliases, but the 
host passed in is the alias which is not in server.xml - tested using 
RequestHeaderExample.  What we need to do is to add additional domain mappings 
without adding Apache or Tomcat configs.  For example if *.xyz.com is being 
handled through Apache, how can that be sent to Tomcat via mod_webapp.  I've 
tested using name based virtual hosting with Apache, but not IP based, without 
success.  I was hoping that the "defaultHost" setting would send any requests 
from hosts not defined in <Host>s to the default, but that doesn't seem to be 
the case.  Thanks!

Quoting August Detlefsen <au...@yahoo.com>:

> In httpd.conf, inside each VirtualHost, you can set the ServerAlias
> directive - it will allow the same VirtualHost to recognize multiple
> domain names: 
> 
> NameVirtualHost 12.34.56.78
> 
> <VirtualHost 12.34.56.78>
>     ServerName myCompany.com
>     ServerAlias myCompany.net myCompany.org myOtherCompany.com
> 
>     #deploy webapps for this site
>     WebAppDeploy     ROOT      conn  /
>     WebAppDeploy     manager   conn  /manager
> 
> </VirtualHost>
> 
> This way you can have multiple domains point to the same <Host> in
> server.xml. I am not sure if Apache passes the original domain name or
> the aliased one to Tomcat though. 
> 
> Otherwise you will have to create multiple <Host>s in server.xml and
> deploy your context in each one. Does anyone know how to configure TC
> to recognize the same webapp across all Hosts?
> 
> -August
> 
> 
> --- tomcat@shwango.com wrote:
> > I've read many posts about virtual hosts and Tomcat with and without 
> > mod_jk/mod_webapp, but haven't found a real answer to my question. 
> > We want to 
> > map multiple hosts to a single <Host> config in server.xml.  I
> > thought the 
> > defaultHost setting would do this, but it doesn't work.  If I have
> > DNS entries 
> > for server1.xyz.com and server2.abc.com that point to the same IP
> > address and 
> > an Apache virtual host and on to mod_webapp, if I don't define and
> > <Host> 
> > settings, Tomcat will serve out any web apps in the webapps
> > directory.  The 
> > problem is that I'd like to run the manager app, but that requires 
> > privileged="true" which (as far as I know) must be done in a
> > <Host><Context> 
> > config.  Basically we want to map multiple domains to a webapp and
> > based on 
> > the "host" value, send a response out.  Kind of along the lines of
> > Apache's 
> > wildcard host syntax.
> > 
> > Hope the post isn't too confusing.  Any ideas?
> > 
> > -Pat
> > 
> > 
> > --
> > To unsubscribe:   <ma...@jakarta.apache.org>
> > For additional commands: <ma...@jakarta.apache.org>
> > Troubles with the list: <ma...@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE Valentine eCards with Yahoo! Greetings!
> http://greetings.yahoo.com
> 
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
> 



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Mapping multiple hosts to single Host

Posted by August Detlefsen <au...@yahoo.com>.
In httpd.conf, inside each VirtualHost, you can set the ServerAlias
directive - it will allow the same VirtualHost to recognize multiple
domain names: 

NameVirtualHost 12.34.56.78

<VirtualHost 12.34.56.78>
    ServerName myCompany.com
    ServerAlias myCompany.net myCompany.org myOtherCompany.com

    #deploy webapps for this site
    WebAppDeploy     ROOT      conn  /
    WebAppDeploy     manager   conn  /manager

</VirtualHost>

This way you can have multiple domains point to the same <Host> in
server.xml. I am not sure if Apache passes the original domain name or
the aliased one to Tomcat though. 

Otherwise you will have to create multiple <Host>s in server.xml and
deploy your context in each one. Does anyone know how to configure TC
to recognize the same webapp across all Hosts?

-August


--- tomcat@shwango.com wrote:
> I've read many posts about virtual hosts and Tomcat with and without 
> mod_jk/mod_webapp, but haven't found a real answer to my question. 
> We want to 
> map multiple hosts to a single <Host> config in server.xml.  I
> thought the 
> defaultHost setting would do this, but it doesn't work.  If I have
> DNS entries 
> for server1.xyz.com and server2.abc.com that point to the same IP
> address and 
> an Apache virtual host and on to mod_webapp, if I don't define and
> <Host> 
> settings, Tomcat will serve out any web apps in the webapps
> directory.  The 
> problem is that I'd like to run the manager app, but that requires 
> privileged="true" which (as far as I know) must be done in a
> <Host><Context> 
> config.  Basically we want to map multiple domains to a webapp and
> based on 
> the "host" value, send a response out.  Kind of along the lines of
> Apache's 
> wildcard host syntax.
> 
> Hope the post isn't too confusing.  Any ideas?
> 
> -Pat
> 
> 
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>