Nginx error says "upstream sent too big header while reading response header from upstream"

My PHP web server with Nginx as reverse proxy says "upstream sent too big header while reading response header from upstream"

And, here is how to fix it:

1. Edit the nginx configuration for my site, for example, /etc/nginx/sites-available/mysite

$ sudo nano /etc/nginx/sites-available/mysite

Modify these lines

...
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_buffer_size 128k;
                fastcgi_buffers 4 256k;
                fastcgi_busy_buffers_size 256k;
        }
...

2. Restart nginx and enjoy

$ sudo systemctl restart nginx

Comments