upstream split a header line in FastCGI records
nginx-forum at nginx.us
Mon Aug 3 23:31:37 MSD 2009
For the past 10 hours I have been trying to find out why my application sometimes generates a "502 Bad Gateway" error and sometimes do not, even though the page output should be nearly identical. The error is described by nginx as "upstream prematurely closed connection while reading response header from upstream" without debug and as "upstream split a header line in FastCGI records" with debug.
This only happens when I'm using FirePHP, a debugging class for PHP, which sends information to browser using headers. It would appear that it only happens when the amount of output from FirePHP reaches a certain value that the error happens, as I don't get any errors if FirePHP outputs only a small amount of debug information.
The error still happens if I create a new PHP script with just FirePHP loaded and use it to output a lot of random strings (preset in script). Yet, the error still only happens sometimes (about 50% chance).
I have tried the latest versions of all 3 branches of nginx (legacy, stable and development) with the same results. PHP is 5.3.0, with php-fpm (spawn-fcgi causes same error) and unix sockets as the link between PHP and nginx (TCP connection causes same error).
My fastcgi settings in nginx are:
fastcgi_buffers 4 256k;
I've ran nginx in debug mode and got logs of a good page and of a bad page:
Bad: http://matrix.alpha-force.net/debug/req2.txt (things go bad at line 250)
I hereby request help. Is it a nginx problem or is it something else?
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4704,4704#msg-4704
More information about the nginx