Welcome! Log In Create A New Profile

Advanced

Wait for backend

Posted by duda 
duda
Wait for backend
June 27, 2018 12:00PM
Hi

I have one backend:

upstream backend_1 {
server 127.0.0.1:35510;
}

and server:

server {
...
location / {
proxy_pass http://backend_1;
}
}


Sometimes I have to restart my backend and it is unavailable for 3-5sec
(port unreachable)

How I can tell nginx to "wait" for backend and do not respond with 502 ?
So it should hold connection for 5 second and if it is unreachable in that
interval responds 502 to client.

Thanks

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280293,280293#msg-280293

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
aT
Re: Wait for backend
June 27, 2018 02:10PM
Look into *proxy_read_timeout* *time*;

https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout

*proxy_connect_timeout* *time*;

https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_connect_timeout

On Wed, Jun 27, 2018 at 1:57 PM duda <[email protected]> wrote:

> Hi
>
> I have one backend:
>
> upstream backend_1 {
> server 127.0.0.1:35510;
> }
>
> and server:
>
> server {
> ...
> location / {
> proxy_pass http://backend_1;
> }
> }
>
>
> Sometimes I have to restart my backend and it is unavailable for 3-5sec
> (port unreachable)
>
> How I can tell nginx to "wait" for backend and do not respond with 502 ?
> So it should hold connection for 5 second and if it is unreachable in that
> interval responds 502 to client.
>
> Thanks
>
> Posted at Nginx Forum:
> https://forum.nginx.org/read.php?2,280293,280293#msg-280293
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>


--
Syed Atif Ali
Desk: 971 4 4493131
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
duda
Re: Wait for backend
June 28, 2018 02:20PM
What is not work: nginx immediately returns "502 Bad Gateway" to the client

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280293,280319#msg-280319

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
duda
Re: Wait for backend
June 28, 2018 02:20PM
*That is

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280293,280320#msg-280320

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Richard Stanway
Re: Wait for backend
July 02, 2018 06:20PM
One way to do this may be to block the port with a firewall rule during
reload. This way nginx will have to wait for the connect timeout (and
hopefully retry) rather than failing immediately after receiving a RST from
the closed port.

On Thu, Jun 28, 2018 at 2:15 PM duda <[email protected]> wrote:

> *That is
>
> Posted at Nginx Forum:
> https://forum.nginx.org/read.php?2,280293,280320#msg-280320
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
duda
Re: Wait for backend
July 02, 2018 07:00PM
That is very sad.
IMHO waiting for backend is a very simple feature, it can be implemented on
nodejs or in Golang in couple lines.
I am surprised that nginx does not support that.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280293,280377#msg-280377

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login