input required on proxy_next_upstream

Francis Daly francis at
Sat Feb 18 10:45:06 UTC 2017

On Wed, Feb 15, 2017 at 10:47:56PM +0530, Kaustubh Deorukhkar wrote:

Hi there,

> For some reason this is not working. Can someone suggest if am missing
> something?

It seems to work fine for me as-is for GET and PUT. And not for POST.

>       proxy_next_upstream error timeout invalid_header http_502 http_503
> http_504;

See "non_idempotent" for POST.

> Note that, in my case one of the upstream server responds early for some
> PUT request with 503 before entire request is read by upstream. I

PUT is idempotent, so it should Just Work.

http {
  upstream local {
  server {
    listen 8880;
    location / {
      proxy_pass http://local;
      proxy_next_upstream error timeout invalid_header http_502 http_503 http_504;
  server {
    listen 8882;
    access_log logs/503.log combined;
    return 503;
  server {
    listen 8883;
    access_log logs/200.log combined;
    return 200 "Got $request\n";

echo xx | curl -v -T -

That gives me a http 200. The log files shows that the request went to
8882, where it got 503, and then went to 8883, where it got 200.

Does that test case work for you?

What part of your system is different from that test case?

(It may be related to the actual upstream response; but once
the difference is identified, that hints at where to do further

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list