Welcome! Log In Create A New Profile

Advanced

Re: upstream: ip_hash and backup

John Moore
June 30, 2011 03:58PM
On 30/06/11 19:49, Maxim Dounin wrote:
> Hello!
>
> On Thu, Jun 30, 2011 at 07:35:24PM +0100, John Moore wrote:
>
>
>> I'm using the upstream module to load balance between 2 back-end
>> servers, using ip_hash to effect a kind of 'stickiness' (making it
>> more likely that subsequent requests from the same client will go to
>> the same back-end server). Now I want to add a 3rd back-end server
>> into the mix, but which will only come into play if the other 2 are
>> failing. There's a handy 'backup' parameter I can use for this,
>> except that according to the docs it cannot be combined with the
>> ip_hash directive. I'm wondering whether there is some other way to
>> achieve what I want here? Effectively, the ip_hash becomes
>> irrelevant once it's failed over to this backup server as there is
>> only one.
>>
> Use error_page based fallback instead, i.e. something like this:
>
> upstream backends {
> ip_hash;
> server 10.0.0.1;
> server 10.0.0.2;
> }
>
> upstream backup {
> server 10.0.0.3;
> }
>
> server {
> ...
>
> location / {
> error_page 502 504 = @fallback;
> proxy_pass http://backends;
> }
>
> location @fallback {
> proxy_pass http://backup;
> }
> }
>
>
>
That's just what I need, thanks. Is this dependent on some recent
version of nginx? I'm running 0.7.65.

John


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

upstream: ip_hash and backup

John Moore June 30, 2011 02:36PM

Re: upstream: ip_hash and backup

Maxim Dounin June 30, 2011 02:50PM

Re: upstream: ip_hash and backup

John Moore June 30, 2011 03:58PM

Re: upstream: ip_hash and backup

Maxim Dounin July 01, 2011 01:54AM

Re: upstream: ip_hash and backup

husseingalal August 11, 2014 06:15AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 155
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready