You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by gisrob <gi...@vanbooth.com> on 2009/04/15 16:44:44 UTC

Virtual Hosts

Can anybody offer any guidance or advice on how I can set up some virtual
hosts for my application that has multiple skins.

I want to be able to go to http://flavour1 instead of having to type in
http://longhostname/service/program.jsp?skins=flavour1, and similar for
flavour2, flavour3, etc..

All the documentation seems to point to virtual directories, and when I have
tried to use the syntax detailed here
http://tomcat.apache.org/tomcat-5.5-doc/virtual-hosting-howto.html
http://gandhim.wordpress.com/2008/01/31/tomcat-55-virtual-directory/
http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_21242062.html

Tomcat tries to open a directory called /service/program.jsp?skins=flavour1/

How do I phrase the context syntax correctly?

MTIA

Rob

-- 
View this message in context: http://www.nabble.com/Virtual-Hosts-tp23060292p23060292.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Virtual Hosts

Posted by David Fisher <df...@jmlafferty.com>.
Hi Charles,

>> I have multiple domains hosted, and I name each as
>> Aliases in the Host in server.xml.
>
> If you only have one <Host> element, aliases are unnecessary.  You  
> only need <Alias> elements when multiple <Host>s are configured and  
> you want Tomcat to route more than one domain to them.

Exactly. We started with Tomcat 3. We have multiple Hosts - localhost  
with internal webapps for monitoring our main webapps and performing  
internal services. We keep a large cache and have a number of jars in  
shared/lib.

We are currently re-architecting so that we can go to Tomcat 6 where  
the games that we have been playing are out of bounds.

We'll have one stack and control access with a Filter and/or Valve.  
This way we have everything in one webapps and it will be a single  
Context that we can put everything into a war - deploy to the Cloud.

> I would hope that configuring such unneeded <Alias> elements doesn't  
> add processing time doing any comparisons, but I haven't looked at  
> the code to verify that.

We can make apache do this work for us in front. I've been lurking on  
this list for some time. In a few weeks we will build our first  
version of this and I am confident that should we encounter trouble I  
can get advice from the good people like you here on the Tomcat users  
list.

Best Regards,
Dave

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


RE: Virtual Hosts

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: David Fisher [mailto:dfisher@jmlafferty.com]
> Subject: Re: Virtual Hosts
> 
> I have multiple domains hosted, and I name each as
> Aliases in the Host in server.xml.

If you only have one <Host> element, aliases are unnecessary.  You only need <Alias> elements when multiple <Host>s are configured and you want Tomcat to route more than one domain to them.

I would hope that configuring such unneeded <Alias> elements doesn't add processing time doing any comparisons, but I haven't looked at the code to verify that.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Virtual Hosts

Posted by David Fisher <df...@jmlafferty.com>.
>> Can anybody offer any guidance or advice on how I can set up some  
>> virtual
>> hosts for my application that has multiple skins.
>>
>> I want to be able to go to http://flavour1 instead of having to  
>> type in
>> http://longhostname/service/program.jsp?skins=flavour1, and similar  
>> for
>> flavour2, flavour3, etc..
>>
>> All the documentation seems to point to virtual directories, and  
>> when I have
>> tried to use the syntax detailed here
>> http://tomcat.apache.org/tomcat-5.5-doc/virtual-hosting-howto.html
>> http://gandhim.wordpress.com/2008/01/31/tomcat-55-virtual-directory/
>> http://www.experts-exchange.com/Web/Web_Servers/Apache/ 
>> Q_21242062.html
>>
>> Tomcat tries to open a directory called /service/program.jsp? 
>> skins=flavour1/
>>
>> How do I phrase the context syntax correctly?
>>
>> MTIA
>>
>> Rob
>>
>
> Write a Servlet Filter that parses HttpServletRequest.getServerName()
> and performs the same action that whatever handles the  
> "skins=flavour1"
> parameter does.
>
> In server.xml set the Engine attribute defaultHost to the single host
> that will handle your application.
>
> (This assumes that you know what you're doing re: DNS)

I use this technique and it works in Tomcat 5.5. I have multiple  
domains hosted, and I name each as Aliases in the Host in server.xml.

This works unless the OP also needs to make https connections. In that  
case, all of the virtual hosts will need to be in the same main domain  
and a wildcard certificate will be required.

*.domain.com

vs.

www.domain1.com
www.domain2.com

If you must use https (which I do) and to have multiple domains then I  
have to choose which domain has the correct certificate and the others  
will not match. That wasn't too awful until Firefox 3. It is a pain.

There is no known (at least to me) solution to this except for putting  
Apache in front of Tomcat and handle the certificates and virtual host  
there.

Then use Filter technique to choose the appropriate skin.

I hope my remarks anticipate the next question from the OP, otherwise  
I'm sorry if this a thread "hijack"

Regards,
Dave


>
>
> p
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


Re: Virtual Hosts

Posted by Pid <p...@pidster.com>.
gisrob wrote:
> Can anybody offer any guidance or advice on how I can set up some virtual
> hosts for my application that has multiple skins.
> 
> I want to be able to go to http://flavour1 instead of having to type in
> http://longhostname/service/program.jsp?skins=flavour1, and similar for
> flavour2, flavour3, etc..
> 
> All the documentation seems to point to virtual directories, and when I have
> tried to use the syntax detailed here
> http://tomcat.apache.org/tomcat-5.5-doc/virtual-hosting-howto.html
> http://gandhim.wordpress.com/2008/01/31/tomcat-55-virtual-directory/
> http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_21242062.html
> 
> Tomcat tries to open a directory called /service/program.jsp?skins=flavour1/
> 
> How do I phrase the context syntax correctly?
> 
> MTIA
> 
> Rob
> 

Write a Servlet Filter that parses HttpServletRequest.getServerName()
and performs the same action that whatever handles the "skins=flavour1"
parameter does.

In server.xml set the Engine attribute defaultHost to the single host
that will handle your application.

(This assumes that you know what you're doing re: DNS)

p

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


Re: Virtual Hosts

Posted by Hassan Schroeder <ha...@gmail.com>.
On Wed, Apr 15, 2009 at 7:44 AM, gisrob <gi...@vanbooth.com> wrote:
>
> Can anybody offer any guidance or advice on how I can set up some virtual
> hosts for my application that has multiple skins.
>
> I want to be able to go to http://flavour1 instead of having to type in
> http://longhostname/service/program.jsp?skins=flavour1, and similar for
> flavour2, flavour3, etc..
>
> All the documentation seems to point to virtual directories, and when I have
> tried to use the syntax detailed here
> http://tomcat.apache.org/tomcat-5.5-doc/virtual-hosting-howto.html

If you followed the above -- showing the relevant part of server.xml
would probably be helpful -- and entered a url like

http://flavour1.example.com/

in your browser,

> Tomcat tries to open a directory called /service/program.jsp?skins=flavour1/

erm, well, that sounds highly unlikely.

> How do I phrase the context syntax correctly?

No idea what that means. Each virtual host will have a ROOT context;
what that contains is up to you.

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

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