If you’re getting this error message
“upstream sent too big header while reading response header from upstream”
in the nginx error log and are using fcgi,
in my case I was running a PHP script via PHP FPM 8.2 and received a 502 response from nginx.
I fixed the issue.
Previously I had this nginx vhost conf for PHP scripts
1 2 3 4 5 6 7 8 9 10 |
location ~ \.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(|/.*)$; include fastcgi_params; fastcgi_param HTTP_PROXY ""; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param QUERY_STRING $query_string; fastcgi_intercept_errors on; fastcgi_pass REDACTED; } |
There are alternate solution for non-fastcgi setups. This however is a fastcgi setup so I have added:
1 2 3 |
fastcgi_buffers 16 32k; fastcgi_buffer_size 64k; fastcgi_busy_buffers_size 64k; |
to the configuration, and reloaded nginx.
The final configuration part looks like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
location ~ \.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(|/.*)$; include fastcgi_params; fastcgi_param HTTP_PROXY ""; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param QUERY_STRING $query_string; fastcgi_intercept_errors on; fastcgi_pass REDACTED; fastcgi_buffers 16 32k; fastcgi_buffer_size 64k; fastcgi_busy_buffers_size 64k; } |