When you see the error “upstream sent too big header while reading response header from upstream” in the Nginx error log, it means that the response headers sent by the upstream server are larger than the buffer size allocated by Nginx to store the headers.
This error can occur when the upstream server sends a large number of cookies or a large amount of data in the headers, causing Nginx to run out of space in the buffer.
Here are some steps you can take to resolve this issue:
- Increase the buffer size for the headers in the Nginx configuration file. You can do this by adding the following line in the http or server block:
large_client_header_buffers 4 16k;
The number 4 indicates the number of buffers, and the number 16k indicates the size of each buffer.
- Decrease the number of cookies sent by the upstream server. This can be done by reducing the number of cookies set by the server, or by increasing the size of the buffer on the upstream server.
- Increase the buffer size in the PHP-FPM configuration file, this can be done by modifying the value of the parameter “request_terminate_timeout” in the PHP-FPM configuration file.
- If the upstream server is an application server, you can check if the server has a limit on the size of the header, if so you can increase this limit.
- If the problem persists, you can try to increase the proxy buffer size in the Nginx configuration file by adding the following line in the http or server block:
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 512k;
It’s important to note that, you will need to adjust the buffer size depending on your specific use case and the amount of traffic your server handles. Additionally, you will need to test the changes before deploying them in a production environment.