You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rao Manekar <ma...@hotmail.com> on 2007/03/02 01:07:11 UTC

RE: how to setup multiple CATALINA_BASE

OK.  Let's see how I can implement this.
Say, I have registered two domain names www.website1.com mapped to IP1 and 
www.website2.com mapped to IP2.

I have my tomcat installed on localhost with two <Host> elements, 
www.website1.com and www.website2.com and applications installed as 
described in documentation.

when I type www.website1.com in my browser, how does that request gets 
routed to <Host1> on my local tomcat installation?

-Rao



>From: "Caldarale, Charles R" <Ch...@unisys.com>

>You don't need multiple CATALINA_BASE settings, nor do you need two
><Connector> elements; instead, use two <Host>s.  Each <Host> must have a
>unique name that matches the DNS name of the IP addresses you wish to
>segregat.  Also, each <Host> should have a unique appBase attribute
>value, and each webapp would be deployed only in the corresponding
>appBase.  Look at:
>http://tomcat.apache.org/tomcat-5.5-doc/config/host.html
>for more information.
>
>  - Chuck
>
>
>THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>MATERIAL and is thus for use only by the intended recipient. If you
>received this in error, please contact the sender and delete the e-mail
>and its attachments from all computers.
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>

_________________________________________________________________
Don’t miss your chance to WIN 10 hours of private jet travel from MicrosoftŽ 
Office Live http://clk.atdmt.com/MRT/go/mcrssaub0540002499mrt/direct/01/


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


RE: how to setup multiple CATALINA_BASE

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rao Manekar [mailto:manekar@hotmail.com] 
> Subject: RE: how to setup multiple CATALINA_BASE
> 
> when I type www.website1.com in my browser, how does that 
> request gets routed to <Host1> on my local tomcat installation?

The host part of the URL is extracted and matched against the set of
configured <Host> names.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


RE: how to setup multiple CATALINA_BASE

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rao Manekar [mailto:manekar@hotmail.com] 
> Subject: Re: how to setup multiple CATALINA_BASE
> 
> If any one in the world type www.cnn.com would that request 
> come to my server and get application under 
> ${catalina.home}/www/appBase/www.cnn.com

Of course not, unless you manage to hack the world's dozen or so master
DNS boxes to route traffic to you.  You must use names that actually
target your system.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


RE: how to setup multiple CATALINA_BASE

Posted by Rao Manekar <ma...@hotmail.com>.
hi guys
I have implemented what I learned.  With simple tomcat installation, it 
works like charm!

I have my two websites working with two different IPs.  Did I say IPs... it 
is not IP dependent :-)

For future reference to other people like me here is what I did in my test 
environment:

1.  Unzipped tomcat 4.0 zip file and did basic tomcat installation and 
tested.  It worked fine.  I stopped tomcat.
2.  Created two separate directories c:\appBase1\website1, 
c:\appBase2\website2.
Copied application files in their corresponding directories.
3.  Modified server.xml as follows:
     a) changed port=80 in <connector> from port=8080
     b) added two <host> elements.

      <!-- Define the website1 virtual host -->
      <Host name="website1" debug="0" appBase="c:\appBase1" 
unpackWARs="false">
        <!-- Tomcat root Context -->
          <Context path="" docBase="website1" debug="0"
                 reloadable="false" crossContext="false">
         </Context>
      </Host>

      <!-- Define the website2 virtual host -->
      <Host name="website2" debug="0" appBase="c:\appBase2" 
unpackWARs="false">
        <!-- Tomcat root Context -->
          <Context path="" docBase="website2" debug="0"
                 reloadable="false" crossContext="false">
         </Context>
      </Host>

4. In my test environment I used windows hosts file and added two (website) 
names with IP addresses of two networkcards on that server.  (In production 
there should be a registered DNS name )
my hosts file looks like this:

127.0.0.1   localhost
x.x.x.x      website1
x.x.x.x      website2

5.  I restarted tomcat and accessesd http://website1 and http://website2 
with out any problem.

Thanks a million for your help.

-rao

_________________________________________________________________
Find what you need at prices you’ll love. Compare products and save at MSNŽ 
Shopping. 
http://shopping.msn.com/default/shp/?ptnrid=37,ptnrdata=24102&tcode=T001MSN20A0701


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


RE: how to setup multiple CATALINA_BASE

Posted by Rao Manekar <ma...@hotmail.com>.
That's better explanation.  I think my 'bulb' started lighting :-)
I will try further from here and make it work.  I will keep you guys posted.

Caldarale, Martin and Hassan thank you for replying to my emails and 
enlightening me.

-rao


>From: "Caldarale, Charles R" <Ch...@unisys.com>
>Reply-To: "Tomcat Users List" <us...@tomcat.apache.org>
>To: "Tomcat Users List" <us...@tomcat.apache.org>
>Subject: RE: how to setup multiple CATALINA_BASE
>Date: Thu, 1 Mar 2007 21:13:38 -0600
>
> > From: Rao Manekar [mailto:manekar@hotmail.com]
> > Subject: Re: how to setup multiple CATALINA_BASE
> >
> > Ok now you are talking IP address.  Offcourse I am working
> > with a registered domain name mapped to a specifi IP address.
> > So, how do I make tomcat recognize it?
>
>Tomcat doesn't have to - only the DNS boxes have to worry about
>translating names to IP octets.
>
> > I want to specify two IP addresses.
>
>Tomcat does not need to know the IP addresses; that's the job of the DNS
>boxes and routers.
>
> > do you have an installation with tomcat referring to two
> > websites with two different IP addresses?
>
>Yes, and it works fine, using one <Connector> and two <Host> elements.
>The <Connector> need not specify an IP address - it just takes whatever
>comes into the box and routes it to the appropriate <Host> based on the
>URL in the HTTP header.  If you have many addresses routed to your box,
>and you want Tomcat to listen to only a subset of them, you'll need to
>put in a <Connector> for each; otherwise, the single <Connector> with no
>address attribute will suffice.  Regardles, the <Connector> elements are
>independent of the <Host> entries.
>
>  - Chuck
>
>
>THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>MATERIAL and is thus for use only by the intended recipient. If you
>received this in error, please contact the sender and delete the e-mail
>and its attachments from all computers.
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>

_________________________________________________________________
Rates near 39yr lows!  $430K Loan for $1,399/mo - Paying Too Much? Calculate 
new payment 
http://www.lowermybills.com/lre/index.jsp?sourceid=lmb-9632-18226&moid=7581


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


RE: how to setup multiple CATALINA_BASE

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rao Manekar [mailto:manekar@hotmail.com] 
> Subject: Re: how to setup multiple CATALINA_BASE
> 
> Ok now you are talking IP address.  Offcourse I am working 
> with a registered domain name mapped to a specifi IP address.
> So, how do I make tomcat recognize it?

Tomcat doesn't have to - only the DNS boxes have to worry about
translating names to IP octets.

> I want to specify two IP addresses.

Tomcat does not need to know the IP addresses; that's the job of the DNS
boxes and routers.

> do you have an installation with tomcat referring to two
> websites with two different IP addresses?

Yes, and it works fine, using one <Connector> and two <Host> elements.
The <Connector> need not specify an IP address - it just takes whatever
comes into the box and routes it to the appropriate <Host> based on the
URL in the HTTP header.  If you have many addresses routed to your box,
and you want Tomcat to listen to only a subset of them, you'll need to
put in a <Connector> for each; otherwise, the single <Connector> with no
address attribute will suffice.  Regardles, the <Connector> elements are
independent of the <Host> entries.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


Re: how to setup multiple CATALINA_BASE

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/1/07, Rao Manekar <ma...@hotmail.com> wrote:

> Let me ask you this, Charles and Hassan, do you have an installation with
> tomcat referring to two websites with two different IP addresses?

Sure, several. Some have one connector that listens on all addresses
*configured on that host*, some have multiple connectors for specific
addresses (to handle SSL, etc.).

Again, if you're still having problems, post your configuration and more
specifics.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


Re: how to setup multiple CATALINA_BASE

Posted by Martin Gainty <mg...@hotmail.com>.
so if your DNS name is www.fubar.com go to command line

nslookup www.fubar.com

will attempt to locate the CNAME records by authoritative DNS servers 
then non-authoritative DNS servers

M--
--------------------------------------------------------------------------- 
This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
--------------------------------------------------------------------------- 
Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
----- Original Message ----- 
From: "Hassan Schroeder" <ha...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Thursday, March 01, 2007 9:13 PM
Subject: Re: how to setup multiple CATALINA_BASE


> On 3/1/07, Rao Manekar <ma...@hotmail.com> wrote:
> 
>> We know that for sure that there is a domain name www.cnn.com registered in
>> DNS.
>> Let's say I create a <Host> element and add my application files under
>> ${catalina.home}/www/appBase/www.cnn.com
> 
> ?! where did you get that path? Never mind, it doesn't matter because...
> 
>> If any one in the world type www.cnn.com would that request come to my
>> server and get application under ${catalina.home}/www/appBase/www.cnn.com
> 
> ..this is so seriously confused. Answer: of course not -- DNS lookups
> will provide the *real* address of CNN as they're supposed to.
> 
> So do you actually have a registered domain? Does the IP address
> point to your server? If so, you're set. Lather, rinse, repeat.  :-)
> 
> -- 
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: how to setup multiple CATALINA_BASE

Posted by Rao Manekar <ma...@hotmail.com>.

>>Let's say I create a <Host> element and add my application files under
>>${catalina.home}/www/appBase/www.cnn.com
>
>?! where did you get that path? Never mind, it doesn't matter because...

http://wiki.apache.org/tomcat/CreateVirtualHosts

>
>>If any one in the world type www.cnn.com would that request come to my
>>server and get application under ${catalina.home}/www/appBase/www.cnn.com
>
>..this is so seriously confused. Answer: of course not -- DNS lookups
>will provide the *real* address of CNN as they're supposed to.

that *real* address of CNN is its IP address.
If my server has a network card with that public IP address and on my server 
my tomcat installation server.xml (<connector> element) has some where in it 
specifies that IP address, offcourse if anyone in the world type WWW.CNN.COM 
that request would come to my server.
In reality Turner broadcasting owns the domain name and IP address and I 
cannot have it.

My point here is that we need to consider IP address along with Host name.

>
>So do you actually have a registered domain? Does the IP address
>point to your server? If so, you're set. Lather, rinse, repeat.  :-)
>

Ok now you are talking IP address.  Offcourse I am working with a registered 
domain name mapped to a specifi IP address.  So, how do I make tomcat 
recognize it?
I want to specify two IP addresses.

Let me ask you this, Charles and Hassan, do you have an installation with 
tomcat referring to two websites with two different IP addresses?

Thank you.

-rao

_________________________________________________________________
Don’t miss your chance to WIN 10 hours of private jet travel from MicrosoftŽ 
Office Live http://clk.atdmt.com/MRT/go/mcrssaub0540002499mrt/direct/01/


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


Re: how to setup multiple CATALINA_BASE

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/1/07, Rao Manekar <ma...@hotmail.com> wrote:

> We know that for sure that there is a domain name www.cnn.com registered in
> DNS.
> Let's say I create a <Host> element and add my application files under
> ${catalina.home}/www/appBase/www.cnn.com

?! where did you get that path? Never mind, it doesn't matter because...

> If any one in the world type www.cnn.com would that request come to my
> server and get application under ${catalina.home}/www/appBase/www.cnn.com

..this is so seriously confused. Answer: of course not -- DNS lookups
will provide the *real* address of CNN as they're supposed to.

So do you actually have a registered domain? Does the IP address
point to your server? If so, you're set. Lather, rinse, repeat.  :-)

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


Re: how to setup multiple CATALINA_BASE

Posted by Rao Manekar <ma...@hotmail.com>.
Hi Charles and Hassan
I tried it did not work.  Let me ask this:
We know that for sure that there is a domain name www.cnn.com registered in 
DNS.
Let's say I create a <Host> element and add my application files under 
${catalina.home}/www/appBase/www.cnn.com

If any one in the world type www.cnn.com would that request come to my 
server and get application under ${catalina.home}/www/appBase/www.cnn.com

-rao



>From: "Hassan Schroeder" <ha...@gmail.com>
>Reply-To: "Tomcat Users List" <us...@tomcat.apache.org>
>To: "Tomcat Users List" <us...@tomcat.apache.org>
>Subject: Re: how to setup multiple CATALINA_BASE
>Date: Thu, 1 Mar 2007 16:55:07 -0800
>
>On 3/1/07, Rao Manekar <ma...@hotmail.com> wrote:
>>As a matter of fact I tried it.  It
>>did not work.  I couldn't figure out the relation between <Host> element 
>>and
>>its IP address.
>
>You don't have to. :-)  And in fact, it's really irrelevant whether the two
>hosts have different IPs or not -- the names, as Charles already said,
>are what are matched.
>
>If you're still having trouble, post the relevant parts of your server.xml.
>
>--
>Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>

_________________________________________________________________
Win a Zune™—make MSNŽ your homepage for your chance to win! 
http://homepage.msn.com/zune?icid=hmetagline


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


Re: how to setup multiple CATALINA_BASE

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/1/07, Rao Manekar <ma...@hotmail.com> wrote:
> As a matter of fact I tried it.  It
> did not work.  I couldn't figure out the relation between <Host> element and
> its IP address.

You don't have to. :-)  And in fact, it's really irrelevant whether the two
hosts have different IPs or not -- the names, as Charles already said,
are what are matched.

If you're still having trouble, post the relevant parts of your server.xml.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


Re: how to setup multiple CATALINA_BASE

Posted by Rao Manekar <ma...@hotmail.com>.
First of all thank you for your reply.  As a matter of fact I tried it.  It 
did not work.  I couldn't figure out the relation between <Host> element and 
its IP address.
I will take your word for it and try it again.
Thank you.

-rao


>From: "Hassan Schroeder" <ha...@gmail.com>
>Reply-To: "Tomcat Users List" <us...@tomcat.apache.org>
>To: "Tomcat Users List" <us...@tomcat.apache.org>
>Subject: Re: how to setup multiple CATALINA_BASE
>Date: Thu, 1 Mar 2007 16:16:22 -0800
>
>On 3/1/07, Rao Manekar <ma...@hotmail.com> wrote:
>.
>>when I type www.website1.com in my browser, how does that request gets
>>routed to <Host1> on my local tomcat installation?
>
>Or to put it another way --
>
>"When I ask for www.website1.com, why does Tomcat give me the
>webapps associated with www.website1.com?"   :-)
>
>Uh, why *wouldn't* it? Isn't that the whole point of named virtual hosts?
>
>And given that's it's trivial to simply /try/ this and see that it does in 
>fact
>work exactly this way...
>
>FWIW,
>--
>Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>

_________________________________________________________________
Don’t miss your chance to WIN 10 hours of private jet travel from MicrosoftŽ 
Office Live http://clk.atdmt.com/MRT/go/mcrssaub0540002499mrt/direct/01/


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


Re: how to setup multiple CATALINA_BASE

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/1/07, Rao Manekar <ma...@hotmail.com> wrote:
.
> when I type www.website1.com in my browser, how does that request gets
> routed to <Host1> on my local tomcat installation?

Or to put it another way --

"When I ask for www.website1.com, why does Tomcat give me the
webapps associated with www.website1.com?"   :-)

Uh, why *wouldn't* it? Isn't that the whole point of named virtual hosts?

And given that's it's trivial to simply /try/ this and see that it does in fact
work exactly this way...

FWIW,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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