How to avoid "too big header" issue?

There’s hundreds of “setcookie(‘xxx’,‘yyy’)” lines in one of my php
page,the size of these cookies is about 2-10KB,so nginx always throw a
typical “502 bad gateway”.

my solutionA is: add this to nginx.conf:

client_header_buffer_size 8m;
large_client_header_buffers 8 8m;
fastcgi_buffer_size 8m;
fastcgi_buffers 8 8m;

result:no effect. I tried increasing the size from 8m to 128m,but it
still give me a 502 errror.

and solution B:

fastcgi_ignore_headers Set-Cookie;

result:no effect. In error log,there’s still a large amount of
‘Set-Cookie’ header info:

2011/04/21 18:28:10 [debug] 66257#0: *2 http fastcgi header:
“Set-Cookie: xxx=yyy; expires=Wed, 21-Apr-2010 10:28:09 GMT”


2011/04/21 18:28:10 [debug] 66257#0: *2 http fastcgi parser: -2
2011/04/21 18:28:10 [debug] 66257#0: *2 upstream split a header line in
FastCGI records
2011/04/21 18:28:10 [error] 66257#0: *2 upstream sent too big header
while reading response header from upstream…

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,192785#msg-192785

On Thu, Apr 21, 2011 at 07:02:27AM -0400, stalkercn wrote:

2011/04/21 18:28:10 [debug] 66257#0: *2 http fastcgi header:
“Set-Cookie: xxx=yyy; expires=Wed, 21-Apr-2010 10:28:09 GMT”


2011/04/21 18:28:10 [debug] 66257#0: *2 http fastcgi parser: -2
2011/04/21 18:28:10 [debug] 66257#0: *2 upstream split a header line in
FastCGI records
2011/04/21 18:28:10 [error] 66257#0: *2 upstream sent too big header
while reading response header from upstream…

Which nginx version do you use ?


Igor S.

The version is 0.8.54. thx.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,193941#msg-193941

fastcgi_buffer doesn’t work,I tried proxy method,it seems working for
me,but slowly:

nginx.log
2011/04/29 11:02:57 [debug] 33323#0: kevent timer: 61402, changes: 0
2011/04/29 11:03:02 [debug] 33323#0: kevent events: 1

When nginx handle one file,the time between two lines is 5 secs,why
here?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,194392#msg-194392

anyone can help me?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,195465#msg-195465

nginx version: nginx/0.8.54
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt=’-I
/usr/local/include’ --with-ld-opt=’-L /usr/local/lib’
–conf-path=/usr/local/etc/nginx/nginx.conf
–sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid
–error-log-path=/var/log/nginx-error.log --user=www --group=www
–with-debug
–http-client-body-temp-path=/var/tmp/nginx/client_body_temp
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp
–http-proxy-temp-path=/var/tmp/nginx/proxy_temp
–http-scgi-temp-path=/var/tmp/nginx/scgi_temp
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp
–http-log-path=/var/log/nginx-access.log
–add-module=/usr/ports/www/nginx/work/ngx_headers_more_module-0.14
–with-http_flv_module --with-http_gzip_static_module
–with-http_image_filter_module --with-http_stub_status_module
–with-pcre

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,195695#msg-195695

On Wed, May 04, 2011 at 10:50:07PM -0400, stalkercn wrote:

–http-scgi-temp-path=/var/tmp/nginx/scgi_temp
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp
–http-log-path=/var/log/nginx-access.log
–add-module=/usr/ports/www/nginx/work/ngx_headers_more_module-0.14
–with-http_flv_module --with-http_gzip_static_module
–with-http_image_filter_module --with-http_stub_status_module
–with-pcre

There was a bug when nginx was built --without-http_cache, but this is
not your case. Could you try nginx-1.0.0 without third-party module
ngx_headers_more_module ?


Igor S.

On Tue, May 03, 2011 at 11:10:53PM -0400, stalkercn wrote:

anyone can help me?

Could you show “nginx -V” output ?


Igor S.

nginx: nginx version: nginx/1.0.1
nginx: built by gcc 4.2.1 20070719 [FreeBSD]
nginx: configure arguments: --prefix=/usr/local/etc/nginx
–with-cc-opt=’-I /usr/local/include’ --with-ld-opt=’-L /usr/local/lib’
–conf-path=/usr/local/etc/nginx/nginx.conf
–sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid
–error-log-path=/var/log/nginx.log --user=www --group=www --with-debug
–http-client-body-temp-path=/var/tmp/nginx/client_body_temp
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp
–http-proxy-temp-path=/var/tmp/nginx/proxy_temp
–http-scgi-temp-path=/var/tmp/nginx/scgi_temp
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp
–http-log-path=/var/log/nginx-access.log --with-http_gzip_static_module
–with-http_stub_status_module --with-pcre

I decrease the fastcgi buffer size and increase the amount of buffers:
fastcgi_buffer_size 64k;
fastcgi_buffers 64 64k;

but a ‘too big header’ error still apears:

[debug] upstream split a header line in FastCGI records
[error] upstream sent too big header while reading response header
from upstream

btw,php is working with Zend-Optimizer,whether this condition can make
the headers bigger than its real size?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,195960#msg-195960

On Thu, May 05, 2011 at 10:45:21PM -0400, stalkercn wrote:

–http-scgi-temp-path=/var/tmp/nginx/scgi_temp
[debug] upstream split a header line in FastCGI records
[error] upstream sent too big header while reading response header
from upstream

Only fastcgi_buffer_size is relevant here.
Could you set it to 512k and make request with debug log ?


Igor S.

http://www.toofiles.com/zh/rawfilesdownload-documents-log-nginx.html

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,195989#msg-195989

http://www.toofiles.com/zh/rawfilesdownload-documents-conf-nginx.html

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,195996#msg-195996

On Fri, May 06, 2011 at 02:34:03AM -0400, stalkercn wrote:

http://www.toofiles.com/zh/rawfilesdownload-documents-log-nginx.html

According to this log nginx uses 4k fastcgi_buffer_size.
Could you show your configuration ?


Igor S.

On Fri, May 06, 2011 at 02:34:03AM -0400, stalkercn wrote:

http://www.toofiles.com/zh/rawfilesdownload-documents-log-nginx.html

nginx does not merge locations as Apache does, so:

    location / {
        root   /home/www;
        index  index.php index.html;
    }

    location ~ \.php$ {
        root           /home/www;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param SCRIPT_FILENAME /home/www$fastcgi_script_name;
        include        fastcgi_params;

        fastcgi_temp_file_write_size 10m;
        fastcgi_busy_buffers_size    512k;
        fastcgi_buffer_size          512k;
        fastcgi_buffers           16 512k;
        fastcgi_connect_timeout      300;
        fastcgi_send_timeout         300;
        fastcgi_read_timeout         300;
        fastcgi_intercept_errors     on;
        fastcgi_next_upstream error invalid_header timeout http_500;
    }


Igor S.

ooh a foolish fault!
But as seem as proxy mode,between two contiguous lines in the debug
log,the time is 4-5 seconds,I dont know why?

eg:
2011/05/06 15:14:10 [debug] 86514#0: *101 http upstream request:
“/general/mytable/intel_view/index.php?”
2011/05/06 15:14:10 [debug] 86514#0: *101 http upstream dummy handler
2011/05/06 15:14:10 [debug] 86514#0: timer delta: 100
2011/05/06 15:14:10 [debug] 86514#0: posted events 0000000000000000
2011/05/06 15:14:10 [debug] 86514#0: worker cycle
2011/05/06 15:14:10 [debug] 86514#0: kevent timer: 299900, changes: 0
2011/05/06 15:14:14 [debug] 86514#0: kevent events: 1
2011/05/06 15:14:14 [debug] 86514#0: kevent: 8: ft:-1 fl:0020
ff:00000000 d:5816 ud:0000000801102150
2011/05/06 15:14:14 [debug] 86514#0: *101 http upstream request:
“/general/mytable/intel_view/index.php?”
2011/05/06 15:14:14 [debug] 86514#0: *101 http upstream process header
2011/05/06 15:14:14 [debug] 86514#0: *101 malloc:
0000000801302000:524288

the full log:
http://www.toofiles.com/zh/rawfilesdownload-documents-7z-nginx_log.html

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,195999#msg-195999

OK,I’ll find out php problem,thanks anyway.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,192785,196007#msg-196007

On Fri, May 06, 2011 at 03:22:23AM -0400, stalkercn wrote:

2011/05/06 15:14:10 [debug] 86514#0: worker cycle
the full log:
http://www.toofiles.com/zh/rawfilesdownload-documents-7z-nginx_log.html

7z format is certainly not the best way to pack report logs.
There is old good gzip: it’s enough.

As to delay, it seems that is is PHP delay.


Igor S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs