upstream sent too big header while reading response header from upstream

Maxim Dounin mdounin at
Mon Feb 10 13:15:03 UTC 2014


On Mon, Feb 10, 2014 at 07:56:22AM -0500, rubenarslan wrote:

> Hi Basti,
> thanks, I found the SO post myself. I had not set up the directives
> properly, so thought the fix didn't work. It does now. I also think they
> described a different problem, as in my case no cookies were sent, headers
> were fairly small and two requests with pretty much identical headers
> sent/received had different results (only 502ed). 
> I'm very interested in learning what exactly may have caused the message in
> my case, so as to know the boundaries in which my requests will work. I now
> set the buffer_size to 8K and I don't see failures with Content-Lengths that
> go far beyond that (though maybe compression has to be considered?).

Another possible cause may be use of $request_body in 
proxy_cache_key.  Cache header, including cache key, is placed 
into proxy buffer if caching is enabled, and effectively reduces 
proxy_buffer_size available to read response headers.

Assuming you are using configs like this one:

it is likely the cause, as the config includes the following lines:

    proxy_cache_methods POST;
    proxy_cache_key "$request_method$request_uri$request_body";

Maxim Dounin

More information about the nginx mailing list