ngx_http_upstream_round_robin.c

Adam Horvath Adam.Horvath at edgeware.tv
Wed May 16 09:23:44 UTC 2018


Hello,
I am totally new to nginx, so please forgive me if I am wrong.

I propose the following change:
https://github.com/nginx/nginx/blob/master/src/http/ngx_http_upstream_round_robin.c#L615
From:    if (state & NGX_PEER_FAILED)
To:      if (state & (NGX_PEER_FAILED || NGX_PEER_NEXT))


Note: The value causing us trouble:
state = NGX_PEER_NEXT // on HTTP 404
Comes from: https://github.com/nginx/nginx/blob/master/src/http/ngx_http_upstream.c#L4097


Regular round robin seems to work fine. But with a configuration like:
upstream live {
    server 10.16.48.227:8090;
    server 10.16.48.228:8090 backup;
}

We get a nice failover for HTTP 502. But for HTTP 404 we get a forever-loop, just like the one mentioned in
Changes with nginx 1.3.0:
    *) Bugfix: nginx might loop infinitely over backends if the
       "proxy_next_upstream" directive with the "http_404" parameter was
       used and there were backup servers specified in an upstream block.

So we get looping despite the fix. The proposed edit stops the looping for us, but I cannot see the full consequences. And of course it is possible that we can fix it by just some configuration change.

What do you think?

Thanks
Adam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20180516/f196cb2b/attachment.html>


More information about the nginx-devel mailing list