502 bad gateway, something about the header?

Does anyone see a problem here? The fastcgi parser returns back a -2,
instead of 0 on a normal request. I don’t see anything wrong with this
header - the only thing that sticks out is the “//” - but still - I
think this is a bug in nginx. Why does it say upstream split a header
line? There are no \n \0 \r etc…

Any help is appreciated - Igor, I sent you a larger chunk of the log
privately unedited (I edited the hostnames to protect the innocent on
this)

Thanks!

2009/08/28 12:17:01 [debug] 20714#0: *7231991 http fastcgi header:
“Set-Cookie:
IBBUSER=pT061zDsSOKTipBqqbbOAJG0RMGGkyUimUAbWHVjZPm4QKksTL16sTHCINiUH22GJoE6hnF3GDiBVFEf3nLovNeXec//EkQa7IclJOOCh2wdQ+PhexQNCg5PKFmU72VQriEyYIDUOQXgfwpWTfvzEeHJnNIGiAVRzNbKBSoQIyKjbgVIfhLV+LAFR3mltZBRS+qYH5AIpdSLtNtGtHVu0Fl9/OfvEBRz2zwsFUhVYW2zPIAG/OX/YVc+NV+M1va1pcWcuwkMgHK4FrYdbXjANymt9BsVo7y0+F3kxqcXmiKJioCSiCd+1fQJnLG0lUClD9qLGSDp9KBz4uzzpsmUYmEXvv2JDOTS+WEBL2+f+j/6wlRHFKYxOls9fZgAR2Lhotro+Rbfhu1iaPkubGKEIHI0FU+366pDWs1IKcy7rtJsHQovG+4Z1bDvx6CYC2yOTJ7VvBIRpFw3z2/v1tNcK9DwI/3lUQ4gdXtAXYtMmo42sO7doi18bKkeIGH8z1DtTrruBbZX4OLhSPts0non1d4yGHrY644PbZXbehW4HKpygqbX6sJobZf4eHzKh1nFkuHZUfZUFroE5yT17Bd/4g==;
domain=.foo.com; expires=Sun, 27-Sep-2009 19:17:01 GMT; path=/”
2009/08/28 12:17:01 [debug] 20714#0: *7231991 http fastcgi parser: -2
2009/08/28 12:17:01 [debug] 20714#0: *7231991 upstream split a header
line in FastCGI records
2009/08/28 12:17:01 [error] 20714#0: *7231991 upstream sent too big
header while reading response header from upstream, client:
134.134.139.72, server: ssl.foo.com, request: “POST
/en-us/login/?TARGET=http%3A%2F%2Ffoo.com%2Fpage%2F HTTP/1.1”,
upstream: “fastcgi://127.0.0.1:11021”, host: “ssl.foo.com”, referrer:
http://foo.com/en-us/login

On Sat, Aug 29, 2009 at 11:10:43AM -0700, Michael S. wrote:

Thanks!
/en-us/login/?TARGET=http%3A%2F%2Ffoo.com%2Fpage%2F HTTP/1.1",
upstream: “fastcgi://127.0.0.1:11021”, host: “ssl.foo.com”, referrer:
http://foo.com/en-us/login

What nginx version do use ? In 0.8.8 there are some bugfixes
in handling FastCGI headers split in records. However, in your case
it seems there is not enough fastcgi_buffer_size.

I will change that and try again. This is using 0.8.11 actually - I
upgraded just in case and it still didn’t help.

2009/8/29 Igor S. [email protected]:

fastcgi_buffers 32 8k;

I have that already…

2009/8/29 Igor S. [email protected]:

On Sat, Aug 29, 2009 at 12:35:47PM -0700, Michael S. wrote:

fastcgi_buffers 32 8k;

I have that already…

Try

fastcgi_buffer_size 16k;
fastcgi_buffers 16 16k;

fastcgi_buffer_size is buffer where response header is read.
It may has different size as compared to fastcgi_buffers.

Igor,

May I also asking too?
I am trying to do “getconf PAGESIZE” and the answer is “4096”.
I am also often have “502 Bad Gateway” page, and I change the settings
to:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

Are those settings to over and make the cpu and memory work harder?

Thank You in advanced Igor.

Regards,
Joe

2009/8/30 Igor S. [email protected]

On Sun, Aug 30, 2009 at 03:51:06AM +0700, Joe wrote:

fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

Are those settings to over and make the cpu and memory work harder?

Thank You in advanced Igor.

It’s better to decrease fastcgi_buffer_size to a value that you really
need.
It may be 16K, 32K, or more. Also, it’s better to create more
fastcgi_buffers of lesser size then small number of large
fastcgi_buffers:

fastcgi_buffers 32 32k;

is better than

fastcgi_buffers 4 256k;

because if you response is 64K, then only two 32K buffers will be
allocated
in the former case, and one 256K in the later case.

Igor,

Thank You very much for your help.
Keep up the good works.

Regards,
Joe

2009/8/30 Igor S. [email protected]

Sorry for the slight highjack. I have a similar issue[1][2], and tried:
fastcgi_buffer_size 16k;
fastcgi_buffers 16 16k;
on my nginx.conf. I also tried:
fastcgi_buffer_size 4k;
fastcgi_buffers 64 16k;
and:
fastcgi_buffer_size 16k;
fastcgi_buffers 64 16k;
I still get both 200 and 502, alternated, at regular intervals. My
pagesize is 4K on an amd64, can i tune these values to something more
suitable? Running 0.8.10 for the moment.

Thanks

[1] alternating 404 and 200
[2] fastcgi causing 502 errors? [was: alternating 404 and 200]

You should look in error_log for reasons of 502s.

You already told me and i already did, which doesn’t mean i understand
the errors :). I get:
*1 recv() failed (104: Connection reset by peer) while reading
response header from upstream
and:
*1 recv() not ready (11: Resource temporarily unavailable)

I attached 2 logs in my other posts. I assume i’m using all the
buffers or something, but i’m clueless. Whenever i compile a new nginx
i don’t even touch the FastCGI’s settings; when i make a new site i
just copy those settings with minimal changes. When i compile 0.8.11
i’ll do it without extra modules and try a very very simple
configuration, and go from there… maybe it’ll help.

But in the meantime i’d like some help solving this.

Thanks,
Nuno

On Sun, Sep 06, 2009 at 12:17:18PM +0100, Nuno Magalh??es wrote:

pagesize is 4K on an amd64, can i tune these values to something more
suitable? Running 0.8.10 for the moment.

Thanks

[1] alternating 404 and 200
[2] fastcgi causing 502 errors? [was: alternating 404 and 200]

You should look in error_log for reasons of 502s.