Upstream Sent Too Big Header While Reading Response Header from Upstream

upstream sent too big header while reading response header from upstream

Add the following to your conf file

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;

502 Bad Gateway error - upstream sent too big header while reading response header from upstream

This is expected behavior as the nginx config for App Engine is using the default proxy_buffer_size which is 4K.

The workaround is to emit HTTP headers that are cumulatively under this limit. There is an open feature request to increase this however it seems it is unlikely to be increased to 128K. If increasing to 128K is the only solution for your use case I suggest creating a request for it with this issue tracker and include the business impact to illustrate the need for the feature.

upstream sent too big header while reading response header from upstream, client (nginx, varnish)

So the answer isnt the best, but it seems to have settled it down.

I bypassed Varnish and setup nginx cache. With little to no impact on page speed.

The base configurations were correct, and without Varnish the errors went away.

Not the best, but, it works.

nginx - upstream sent too big header while reading response header from upstream

If you're capable of reconstructing exact POST request via curl or otherwise measure the actual header size, you can specify the proper size for uwsgi_buffer_size (the directive that is related in your case).

Here's my post that has some insight into a similiar directive, proxy_buffer_size. There are many *_buffer_size directives, each "proxy"-like NGINX module has one (fastcgi, proxy, uwsgi), but how you approach their tuning (and how they essentially work) is the same.

You can try, without measurement, by placing directly in server block:

uwsgi_buffer_size 16k; 
uwsgi_busy_buffers_size 24k;


Related Topics



Leave a reply



Submit