input required on proxy_next_upstream

Francis Daly francis at
Tue Feb 21 20:18:37 UTC 2017

On Tue, Feb 21, 2017 at 04:45:09AM -0500, kaustubh wrote:

Hi there,

> Thanks Francis! I was able to test that above works.

Good stuff -- at least we can see that things are fundamentally correct.

> But problem is when we have proxy buffering off and when we try to send
> large file say 1gb, it fails with 502 without trying next instance.

Ah, yes, as you point out: that's the documented current expected

> Any suggestions? May be is there a way where nginx can expect-100 from
> upstream before starting to send data to it, so if expect-100 fails, it can
> try next instance without losing data already sent otherwise?

I'm pretty sure that that is not doable just in nginx.conf with the
current stock code.

You'll want to have some new code to either do that (issue the request
headers, wait long enough for it to have a chance to fail before streaming
the request body (while presumably buffering the start of the request body
somewhere)); or to always buffer the request body but simultaneously send
it upstream, so that on failure the body can be re-sent from the start.

Maybe that can be done with one of the embedded-language modules, but
it sounds to me like it would best be done in the proxy module itself.

The usual path there is to decide how important that behaviour is to you,
and then either write the code to do it, or encourage someone else to
write the code for you.

If the design and code are clean, and the owner is happy to share,
I suspect that it could be a welcome addition to the stock code.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list