Welcome! Log In Create A New Profile

Advanced

Nginx Proxy redirect to clients when upstreams are busy

December 11, 2015 06:54AM
Hi,

I have built a custom load balancer "my_loadbalancer" which load balances
request from end users.

-Ignore any syntax errors, if any-

upstream myservers {
my_loadbalancer;
server abc123;
server pqr123;
}

location XYZ {
proxy_pass http://myservers http://abcdservers ;
}

I have basically followed Emiller's Guide to get all this working.
"my_loadbalancer" loadbalances upstreams based on some conditions. Right
now, loadbalancer's "get_peer" function returns
(1) NGX_OK when it successfully finds upstream
(2) NGX_BUSY when it fails to find upstream.


In above case (1) works fine and client gets response and case (2) works
fine, loadbalancer sends the client a 502 Bad Gateway.

Now I want to do something more where I need help.
In case (2), instead of sending a 502, I would like loadbalancer to send a
redirect (either 301 or 302, not decided yet) so that client gets a
redirect and connects to completely different Loadbalancer.

I'm looking at ngx_http_upstream_connect() in ngx_http_upstream.c where
return from loadbalancer is handled. I dont see a simple way to make it
generate redirect response.


I want to do this programtically because the different loadbalancer
instance which I want the client should connect to(indicated through
redirect) is decided on the fly.


Anyone has any inputs/suggestions ? Thanks!

Regards
Prasanna
--
Best Regards
Prasanna Khanapur
Oslo, Norway
Mobile: +4795417774
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Nginx Proxy redirect to clients when upstreams are busy

pk123 785 December 11, 2015 06:54AM

Re: Nginx Proxy redirect to clients when upstreams are busy

Maxim Dounin 396 December 11, 2015 08:38AM

RE: Nginx Proxy redirect to clients when upstreams are busy

pk123 513 December 11, 2015 04:36PM

Re: Nginx Proxy redirect to clients when upstreams are busy

Maxim Dounin 309 December 14, 2015 10:08AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 149
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready