max header length from fastcgi?

Igor Sysoev is at rambler-co.ru
Thu Aug 6 15:51:33 MSD 2009


On Thu, Aug 06, 2009 at 12:44:44PM +0100, Magnus Leuthner wrote:

> I have a little issue: I try to send out a quite big header from my
> fastcgi application (using libfastcgi, FCGX). The headers contain
> about 30 Set-Cookie records. Nginx only gives an 502 Bad Gateway error
> when I try to send that through nginx.
> 
> Please let me know how to increase the maximum header size in nginx,
> preferably in the configuration, but if there is no config hook for
> this a hint to where to change a Macro in the code would be
> appreciated as well.

Probably, you need to increase fastcgi buffers:

fastcgi_buffer_size  32k;
fastcgi_buffers      4  32k;

Apply the attached patch also.


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/modules/ngx_http_fastcgi_module.c
===================================================================
--- src/http/modules/ngx_http_fastcgi_module.c	(revision 2329)
+++ src/http/modules/ngx_http_fastcgi_module.c	(revision 2331)
@@ -1065,7 +1065,7 @@
 static ngx_int_t
 ngx_http_fastcgi_process_header(ngx_http_request_t *r)
 {
-    u_char                         *p, *start, *last, *part_start;
+    u_char                         *p, *start, *last, *part_start, *part_end;
     size_t                          size;
     ngx_str_t                      *status_line, line, *pattern;
     ngx_int_t                       rc, status;
@@ -1237,6 +1237,7 @@
         for ( ;; ) {
 
             part_start = u->buffer.pos;
+            part_end = u->buffer.last;
 
             rc = ngx_http_parse_header_line(r, &u->buffer, 1);
 
@@ -1437,8 +1438,12 @@
         part = ngx_array_push(f->split_parts);
 
         part->start = part_start;
-        part->end = u->buffer.last;
+        part->end = part_end;
 
+        if (u->buffer.pos < u->buffer.last) {
+            continue;
+        }
+
         return NGX_AGAIN;
     }
 }


More information about the nginx mailing list