You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by anton <wa...@yahoo.com> on 2007/03/08 00:08:38 UTC

[users@httpd] Help: how to configure multiple apache servers behind a hardware load balancer

Hi there,

I'm a decently experienced apache user on ONE
webserver.  I'm trying to switch to two apache servers
behind a Foundry hardware load balancer.

I need a tutorial which would explain how to configure
multiple apache servers behind a hardware load
balancer.

I have a domain name correctly resolving to the
balancer's ip and the balancer correctly forwarding
the requests to each server.  That's working fine. 
Things get confusing when I try to configure each
server's ServerName and virtual hosts.

Any help would be greatly appreciated.

Cheers,
Anton

---------------------------------------------------------------------
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] Help: how to configure multiple apache servers behind a hardware load balancer

Posted by anton <wa...@yahoo.com>.
Thanks again for your suggestions, Matt.  I got it
working by using a slightly different approach.  My
guess is that apache had an issue (again, only with
multiple servers) when the first virtual server was a
redirect.  By changing the httpd.conf section included
earlier to the following one (note the subtle
differences), everything works correctly now:

...
ServerName www.mydomain.com:80
...
NameVirtualHost *:80
<VirtualHost *:80>
   DocumentRoot /var/www/public_html
   ServerName www.mydomain.com
</VirtualHost>
<VirtualHost *:80>
   Redirect permanent / http://www.mydomain.com/
   ServerName mydomain.com
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot /var/www/partner1
   ServerName partner1.mydomain.com
</VirtualHost>
... 

Cheers,
Anton


--- matt farey <ma...@gmail.com> wrote:

> anton wrote:
> > Thanks, Matt.  I'll try the packet sniffer next. 
> > Meanwhile, I narrowed the problem down to virtual
> > hosts.  Here's the http.conf on each server:
> >
> > ...
> > ServerName mydomain.com:80
> > ...
> > NameVirtualHost *:80
> > # redirect mydomain.com to www.mydomain.com
> > # has to match ServerName above
> > <VirtualHost *:80>
> >    Redirect permanent / http://www.mydomain.com/
> >    ServerName mydomain.com
> > </VirtualHost>
> > # provide webroot for the above redirect
> > <VirtualHost *:80>
> >    DocumentRoot /var/www/public_html
> >    ServerName www.mydomain.com
> > </VirtualHost>
> > # allow partner1.mydomain.com to work
> > <VirtualHost *:80>
> >    DocumentRoot /var/www/partner1
> >    ServerName partner1.mydomain.com
> > </VirtualHost>
> > ... 
> >
> > So, this makes 10% of the requests fail.  If I
> comment
> > out all of the virtual host stuff above,
> everything
> > works (but then, of course, I don't get canonical
> > hostname or partner1 to work).
> >
> > Anton
> >
> >   
> 
> First thing, say you have load balancer L in front
> of A and B, do
> 
> mydomain.com, www.mydomain.com and
> partner1.mydomain.com
> 
> all resolve to machine A from A, and to B when on B?
> sit on A and perform nslookup for the hosts do they
> return A's IP, what for B?
> 
> I am thinking here that www.mydomain.com might be
> resolving back to L which forwards onto A or B, and
> the loop continues, resulting in the hard redirect
> limit being reached. You could verify this using
> fiddler or paros while making the request. If the
> _browsers_ hard redirect limit is reached you will
> see. If it is a limit with the server it will show
> up with Wireshark.
> 
> That's all I can think of really. Sorry.
> 
> 
> 
> 
>
---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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] Help: how to configure multiple apache servers behind a hardware load balancer

Posted by matt farey <ma...@gmail.com>.
anton wrote:
> Thanks, Matt.  I'll try the packet sniffer next. 
> Meanwhile, I narrowed the problem down to virtual
> hosts.  Here's the http.conf on each server:
>
> ...
> ServerName mydomain.com:80
> ...
> NameVirtualHost *:80
> # redirect mydomain.com to www.mydomain.com
> # has to match ServerName above
> <VirtualHost *:80>
>    Redirect permanent / http://www.mydomain.com/
>    ServerName mydomain.com
> </VirtualHost>
> # provide webroot for the above redirect
> <VirtualHost *:80>
>    DocumentRoot /var/www/public_html
>    ServerName www.mydomain.com
> </VirtualHost>
> # allow partner1.mydomain.com to work
> <VirtualHost *:80>
>    DocumentRoot /var/www/partner1
>    ServerName partner1.mydomain.com
> </VirtualHost>
> ... 
>
> So, this makes 10% of the requests fail.  If I comment
> out all of the virtual host stuff above, everything
> works (but then, of course, I don't get canonical
> hostname or partner1 to work).
>
> Anton
>
>   

First thing, say you have load balancer L in front of A and B, do

mydomain.com, www.mydomain.com and partner1.mydomain.com

all resolve to machine A from A, and to B when on B?
sit on A and perform nslookup for the hosts do they return A's IP, what for B?

I am thinking here that www.mydomain.com might be resolving back to L which forwards onto A or B, and the loop continues, resulting in the hard redirect limit being reached. You could verify this using fiddler or paros while making the request. If the _browsers_ hard redirect limit is reached you will see. If it is a limit with the server it will show up with Wireshark.

That's all I can think of really. Sorry.




---------------------------------------------------------------------
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] Help: how to configure multiple apache servers behind a hardware load balancer

Posted by anton <wa...@yahoo.com>.
Thanks, Matt.  I'll try the packet sniffer next. 
Meanwhile, I narrowed the problem down to virtual
hosts.  Here's the http.conf on each server:

...
ServerName mydomain.com:80
...
NameVirtualHost *:80
# redirect mydomain.com to www.mydomain.com
# has to match ServerName above
<VirtualHost *:80>
   Redirect permanent / http://www.mydomain.com/
   ServerName mydomain.com
</VirtualHost>
# provide webroot for the above redirect
<VirtualHost *:80>
   DocumentRoot /var/www/public_html
   ServerName www.mydomain.com
</VirtualHost>
# allow partner1.mydomain.com to work
<VirtualHost *:80>
   DocumentRoot /var/www/partner1
   ServerName partner1.mydomain.com
</VirtualHost>
... 

So, this makes 10% of the requests fail.  If I comment
out all of the virtual host stuff above, everything
works (but then, of course, I don't get canonical
hostname or partner1 to work).

Anton


--- matt farey <ma...@gmail.com> wrote:

> 
> anton wrote:
> > Thanks, Krist.  I thought that it should work in
> > theory too, but it doesn't in practice :( 
> Basically,
> > about 10% of requests to www.mydomain.com fail
> (time
> > out) if I set the servernames to www.mydomain.com
> for
> > both servers and then try to use VirtualHosts.  We
> > have to use virtualhosts because we need things
> like
> > partner1.mydomain.com and partner2.mydomain.com.
> >
> > I am not sure what to do at this point.
> >
> > Anton
> >
> > --- Krist van Besien <kr...@gmail.com>
> > wrote:
> >
> >   
> >> On 3/8/07, anton <wa...@yahoo.com> wrote:
> >>     
> >>> Hi there,
> >>>
> >>> I'm a decently experienced apache user on ONE
> >>> webserver.  I'm trying to switch to two apache
> >>>       
> >> servers
> >>     
> >>> behind a Foundry hardware load balancer.
> >>>
> >>> I need a tutorial which would explain how to
> >>>       
> >> configure
> >>     
> >>> multiple apache servers behind a hardware load
> >>> balancer.
> >>>
> >>> I have a domain name correctly resolving to the
> >>> balancer's ip and the balancer correctly
> >>>       
> >> forwarding
> >>     
> >>> the requests to each server.  That's working
> fine.
> >>> Things get confusing when I try to configure
> each
> >>> server's ServerName and virtual hosts.
> >>>
> >>> Any help would be greatly appreciated.
> >>>       
> >> You just need to make sure each server has the
> >> server name that the
> >> client sees. So if you have
> >> www.mydomain.com
> >> and this resolves correctly to the loadbalancer
> than
> >> you just  need to have
> >> ServerName www.mydomain.com
> >> in your config on each server.
> >>
> >> In theory you could even run each webserver with
> the
> >> same httpd.conf.
> >>
> >> Krist
> >>
> >> -- 
> >> krist.vanbesien@gmail.com
> >> Bremgarten b. Bern, Switzerland
> >> --
> >> A: It reverses the normal flow of conversation.
> >> Q: What's wrong with top-posting?
> >> A: Top-posting.
> >> Q: What's the biggest scourge on plain text email
> >> discussions?
> >>
> >>
> >>     
> >
>
---------------------------------------------------------------------
> >   
> >> 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
> >>
> >>
> >>     
> >
> >
> >
>
---------------------------------------------------------------------
> > 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
> >
> >
> >   
> this might sound silly, but since neither backend
> server needs DNS, do
> you have hostname lookups off, do you have all your
> vhosts of the form
> <vhost  ip:port>
> servername www.mydomain.com
> </vhost>
> rather than
> <vhost www.mydomain.com:port>
> servername www.mydomain.com
> </vhost>
> could this be a hosts or DNS issue, a throw over
> from when things
> referred to different NICs/IPs, have you tried a
> packet sniffer like
> wireshark - my answer to almost every apache
> debuggering session, and
> tried to see why those tcp requests aren't
> happening, or whether its a
> http issue?
> ignore me if I'm barking incoherently.
> matt
> 
> 
> 
>
---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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] Help: how to configure multiple apache servers behind a hardware load balancer

Posted by matt farey <ma...@gmail.com>.
anton wrote:
> Thanks, Krist.  I thought that it should work in
> theory too, but it doesn't in practice :(  Basically,
> about 10% of requests to www.mydomain.com fail (time
> out) if I set the servernames to www.mydomain.com for
> both servers and then try to use VirtualHosts.  We
> have to use virtualhosts because we need things like
> partner1.mydomain.com and partner2.mydomain.com.
>
> I am not sure what to do at this point.
>
> Anton
>
> --- Krist van Besien <kr...@gmail.com>
> wrote:
>
>   
>> On 3/8/07, anton <wa...@yahoo.com> wrote:
>>     
>>> Hi there,
>>>
>>> I'm a decently experienced apache user on ONE
>>> webserver.  I'm trying to switch to two apache
>>>       
>> servers
>>     
>>> behind a Foundry hardware load balancer.
>>>
>>> I need a tutorial which would explain how to
>>>       
>> configure
>>     
>>> multiple apache servers behind a hardware load
>>> balancer.
>>>
>>> I have a domain name correctly resolving to the
>>> balancer's ip and the balancer correctly
>>>       
>> forwarding
>>     
>>> the requests to each server.  That's working fine.
>>> Things get confusing when I try to configure each
>>> server's ServerName and virtual hosts.
>>>
>>> Any help would be greatly appreciated.
>>>       
>> You just need to make sure each server has the
>> server name that the
>> client sees. So if you have
>> www.mydomain.com
>> and this resolves correctly to the loadbalancer than
>> you just  need to have
>> ServerName www.mydomain.com
>> in your config on each server.
>>
>> In theory you could even run each webserver with the
>> same httpd.conf.
>>
>> Krist
>>
>> -- 
>> krist.vanbesien@gmail.com
>> Bremgarten b. Bern, Switzerland
>> --
>> A: It reverses the normal flow of conversation.
>> Q: What's wrong with top-posting?
>> A: Top-posting.
>> Q: What's the biggest scourge on plain text email
>> discussions?
>>
>>
>>     
> ---------------------------------------------------------------------
>   
>> 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
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> 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
>
>
>   
this might sound silly, but since neither backend server needs DNS, do
you have hostname lookups off, do you have all your vhosts of the form
<vhost  ip:port>
servername www.mydomain.com
</vhost>
rather than
<vhost www.mydomain.com:port>
servername www.mydomain.com
</vhost>
could this be a hosts or DNS issue, a throw over from when things
referred to different NICs/IPs, have you tried a packet sniffer like
wireshark - my answer to almost every apache debuggering session, and
tried to see why those tcp requests aren't happening, or whether its a
http issue?
ignore me if I'm barking incoherently.
matt



---------------------------------------------------------------------
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] Help: how to configure multiple apache servers behind a hardware load balancer

Posted by anton <wa...@yahoo.com>.
Thanks, Krist.  I thought that it should work in
theory too, but it doesn't in practice :(  Basically,
about 10% of requests to www.mydomain.com fail (time
out) if I set the servernames to www.mydomain.com for
both servers and then try to use VirtualHosts.  We
have to use virtualhosts because we need things like
partner1.mydomain.com and partner2.mydomain.com.

I am not sure what to do at this point.

Anton


--- Krist van Besien <kr...@gmail.com>
wrote:

> On 3/8/07, anton <wa...@yahoo.com> wrote:
> > Hi there,
> >
> > I'm a decently experienced apache user on ONE
> > webserver.  I'm trying to switch to two apache
> servers
> > behind a Foundry hardware load balancer.
> >
> > I need a tutorial which would explain how to
> configure
> > multiple apache servers behind a hardware load
> > balancer.
> >
> > I have a domain name correctly resolving to the
> > balancer's ip and the balancer correctly
> forwarding
> > the requests to each server.  That's working fine.
> > Things get confusing when I try to configure each
> > server's ServerName and virtual hosts.
> >
> > Any help would be greatly appreciated.
> 
> You just need to make sure each server has the
> server name that the
> client sees. So if you have
> www.mydomain.com
> and this resolves correctly to the loadbalancer than
> you just  need to have
> ServerName www.mydomain.com
> in your config on each server.
> 
> In theory you could even run each webserver with the
> same httpd.conf.
> 
> Krist
> 
> -- 
> krist.vanbesien@gmail.com
> Bremgarten b. Bern, Switzerland
> --
> A: It reverses the normal flow of conversation.
> Q: What's wrong with top-posting?
> A: Top-posting.
> Q: What's the biggest scourge on plain text email
> discussions?
> 
>
---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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] Help: how to configure multiple apache servers behind a hardware load balancer

Posted by Krist van Besien <kr...@gmail.com>.
On 3/8/07, anton <wa...@yahoo.com> wrote:
> Hi there,
>
> I'm a decently experienced apache user on ONE
> webserver.  I'm trying to switch to two apache servers
> behind a Foundry hardware load balancer.
>
> I need a tutorial which would explain how to configure
> multiple apache servers behind a hardware load
> balancer.
>
> I have a domain name correctly resolving to the
> balancer's ip and the balancer correctly forwarding
> the requests to each server.  That's working fine.
> Things get confusing when I try to configure each
> server's ServerName and virtual hosts.
>
> Any help would be greatly appreciated.

You just need to make sure each server has the server name that the
client sees. So if you have
www.mydomain.com
and this resolves correctly to the loadbalancer than you just  need to have
ServerName www.mydomain.com
in your config on each server.

In theory you could even run each webserver with the same httpd.conf.

Krist

-- 
krist.vanbesien@gmail.com
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
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