Php – how to fix upstream sent too big header while reading response header from upstream

nginxPHP

I have this error in my log :

upstream sent too big header while reading response header from upstream

And I tried to add

proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;

to my nginx.conf http block but did not work

I also tried to add

fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

to my conf file but I could not locate any location ~ .php$ {

So I wonder how I can over come this error ?
adding

fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

to a hand made php block gives me nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:6

Best Answer

Usually this parameters fix "upstream sent too big header" issue, and you dont need huge values for them :) And set them for http or server blocks, not location.

server {
...
    fastcgi_buffers  16 16k;
    fastcgi_buffer_size  32k;
}

Also sometimes FirePHP for Firefox creates large headers, try to disable it temporarily.