You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Reka Thirunavukkarasu <rt...@gmail.com> on 2012/05/29 13:35:42 UTC

Accessing Virtual Host through load blancer

Hi

I'm configuring a load balancer in front of two tomcat instances in
the same machine. I wanted to access my name based virtual host which
was created across those two tomcat instances through load balancer.
In this case, when i send a request like the following: say my load
balancer is running in port 8280 as https:

                           https://VirtualHostName:8280/

The request at the tomcat is to localhost not to the above
VirtualHost. Can i be able to access name based virtual host through a
load balancer in tomcat, since the mapping in load balancer is to the
actual tomcat instances not to the virtual host. Could you please let
me know how to overcome such an issue in tomcat?


Thanks,
Reka

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


Re: Accessing Virtual Host through load blancer

Posted by Reka Thirunavukkarasu <rt...@gmail.com>.
Hi,

I'm using tomcat 7.0.27 and java 1.6 in ubuntu 11.10.

Here I'm not using Apache httpd instead the load balancer that we have
developed which will balance load within tomcat instances.

Obviously, the issue is with our load balancer since it is rewriting
the url to one of the actual running tomcat instance though the
request is to virtual host. Since we plan to use our load balancer, we
plan to send additional http header with virtual host information to
tomcat. In this case, how could i handle it in tomcat level?

I have defined the virtual hosts in Server.xml. And i have deployed
web applications inside the virtual host as well. When i was trying to
invoke those web application through virtual host from load balancer
only, i got the above problem.


Thanks,
Reka

On Tue, May 29, 2012 at 5:16 PM, Casper Wandahl Schmidt
<ka...@gmail.com> wrote:
>
> Den 29-05-2012 13:35, Reka Thirunavukkarasu skrev:
>
>> Hi
>>
>> I'm configuring a load balancer in front of two tomcat instances in
>> the same machine. I wanted to access my name based virtual host which
>> was created across those two tomcat instances through load balancer.
>> In this case, when i send a request like the following: say my load
>> balancer is running in port 8280 as https:
>>
>>                            https://VirtualHostName:8280/
>>
>> The request at the tomcat is to localhost not to the above
>> VirtualHost. Can i be able to access name based virtual host through a
>> load balancer in tomcat, since the mapping in load balancer is to the
>> actual tomcat instances not to the virtual host. Could you please let
>> me know how to overcome such an issue in tomcat?
>
> I think you need the <Host> element in your server.xml on each tomcat but
> it's hard to say since you have said nothing about your environment or
> configurations. I have apache httpd in front of tomcat (using mod_jk without
> loadbalancing) and uses it to access virtual hostnames (named based) without
> any problem.
>>
>>
>>
>> Thanks,
>> Reka
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> Med venlig hilsen/Kind regards
> Casper W. Schmidt
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>



-- 
Regards,
Reka
:)

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


Re: Accessing Virtual Host through load blancer

Posted by Reka Thirunavukkarasu <rt...@gmail.com>.
Thanks for the insight information.

> Don't /plan/ to do it, /do it/.  You /must/ send a "Host:" header to Tomcat,
> to allow it to pick the correct VirtualHost.  Otherwise how would it do it ?
> That's the HTTP/1.1 protocol, nothing special with Tomcat.
 Then we will implement it.

Reka.

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


Re: Accessing Virtual Host through load blancer

Posted by André Warnier <aw...@ice-sa.com>.
Please do not top-post.
Answer below the respective question or comment, not on top of the message.
We don't like to have to scroll up and down to see which answer related to what.

Reka Thirunavukkarasu wrote:
> Hi,
> 
> I'm using tomcat 7.0.27 and java 1.6 in ubuntu 11.10.
> 
> Here I'm not using Apache httpd instead the load balancer that we have
> developed which will balance load within tomcat instances.
> 
> Obviously, the issue is with our load balancer since it is rewriting
> the url to one of the actual running tomcat instance though the
> request is to virtual host. Since we plan to use our load balancer, we
> plan to send additional http header with virtual host information to
> tomcat.

Don't /plan/ to do it, /do it/.  You /must/ send a "Host:" header to Tomcat, to allow it 
to pick the correct VirtualHost.  Otherwise how would it do it ?
That's the HTTP/1.1 protocol, nothing special with Tomcat.

  In this case, how could i handle it in tomcat level?

Tomcat will handle it fine, if you send a correct request.
A HTTP 1.1 request without a Host: header is incorrect.

> 
> I have defined the virtual hosts in Server.xml. And i have deployed
> web applications inside the virtual host as well. When i was trying to
> invoke those web application through virtual host from load balancer
> only, i got the above problem.
> 

Tomcat is doing what it should do : no "Host:" header in the request, with a value 
matching a (Virtual) Host name ? --> handle with the default Host.



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


Re: Accessing Virtual Host through load blancer

Posted by Reka Thirunavukkarasu <rt...@gmail.com>.
Hi,

I'm using tomcat 7.0.27 and java 1.6 in ubuntu 11.10.

Here I'm not using Apache httpd instead the load balancer that we have
developed which will balance load within tomcat instances.

Obviously, the issue is with our load balancer since it is rewriting
the url to one of the actual running tomcat instance though the
request is to virtual host. Since we plan to use our load balancer, we
plan to send additional http header with virtual host information to
tomcat. In this case, how could i handle it in tomcat level?

I have defined the virtual hosts in Server.xml. And i have deployed
web applications inside the virtual host as well. When i was trying to
invoke those web application through virtual host from load balancer
only, i got the above problem.


Thanks,
Reka

On Tue, May 29, 2012 at 5:16 PM, Casper Wandahl Schmidt
<ka...@gmail.com> wrote:
>
> Den 29-05-2012 13:35, Reka Thirunavukkarasu skrev:
>
>> Hi
>>
>> I'm configuring a load balancer in front of two tomcat instances in
>> the same machine. I wanted to access my name based virtual host which
>> was created across those two tomcat instances through load balancer.
>> In this case, when i send a request like the following: say my load
>> balancer is running in port 8280 as https:
>>
>>                            https://VirtualHostName:8280/
>>
>> The request at the tomcat is to localhost not to the above
>> VirtualHost. Can i be able to access name based virtual host through a
>> load balancer in tomcat, since the mapping in load balancer is to the
>> actual tomcat instances not to the virtual host. Could you please let
>> me know how to overcome such an issue in tomcat?
>
> I think you need the <Host> element in your server.xml on each tomcat but
> it's hard to say since you have said nothing about your environment or
> configurations. I have apache httpd in front of tomcat (using mod_jk without
> loadbalancing) and uses it to access virtual hostnames (named based) without
> any problem.
>>
>>
>>
>> Thanks,
>> Reka
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> Med venlig hilsen/Kind regards
> Casper W. Schmidt
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>



-- 
Regards,
Reka
:)

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


Re: Accessing Virtual Host through load blancer

Posted by Casper Wandahl Schmidt <ka...@gmail.com>.
Den 29-05-2012 13:35, Reka Thirunavukkarasu skrev:
> Hi
>
> I'm configuring a load balancer in front of two tomcat instances in
> the same machine. I wanted to access my name based virtual host which
> was created across those two tomcat instances through load balancer.
> In this case, when i send a request like the following: say my load
> balancer is running in port 8280 as https:
>
>                             https://VirtualHostName:8280/
>
> The request at the tomcat is to localhost not to the above
> VirtualHost. Can i be able to access name based virtual host through a
> load balancer in tomcat, since the mapping in load balancer is to the
> actual tomcat instances not to the virtual host. Could you please let
> me know how to overcome such an issue in tomcat?
I think you need the <Host> element in your server.xml on each tomcat 
but it's hard to say since you have said nothing about your environment 
or configurations. I have apache httpd in front of tomcat (using mod_jk 
without loadbalancing) and uses it to access virtual hostnames (named 
based) without any problem.
>
>
> Thanks,
> Reka
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
Med venlig hilsen/Kind regards
Casper W. Schmidt


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


Re: Accessing Virtual Host through load blancer

Posted by André Warnier <aw...@ice-sa.com>.
Reka Thirunavukkarasu wrote:

> Hi
> 
> I'm configuring a load balancer in front of two tomcat instances in
> the same machine. I wanted to access my name based virtual host which
> was created across those two tomcat instances through load balancer.
> In this case, when i send a request like the following: say my load
> balancer is running in port 8280 as https:
> 
>                            https://VirtualHostName:8280/
> 
> The request at the tomcat is to localhost not to the above
> VirtualHost. Can i be able to access name based virtual host through a
> load balancer in tomcat, since the mapping in load balancer is to the
> actual tomcat instances not to the virtual host. Could you please let
> me know how to overcome such an issue in tomcat?
> 

To allow people to answer in a relevant way, could you give some details about what 
version of Tomcat you are using, under which version of Java, under which platform ?

And, most importantly, what you are actually using to do the load-balancing.
Are you using Apache httpd as a front-end ? if yes, with which proxying mechanism to 
Tomcat (mod_proxy, mod_jk, .. ?) (and versions of ditto).
If not Apache httpd, then what ?

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