I am getting this error from Nginx, but can't seem to figure it out! I am using codeigniter and am using the database for sessions. So I'm wondering how the header can ever be too big. Is there anyway to check what the header is? or potentially see what I can do to fix this error?
Let me know if you need me to put up any conf files or whatever and I'll update as you request them
2012/12/15 11:51:39 [error] 2007#0: *5778 upstream sent too big header while reading response header from upstream, client: 24.63.77.149, server: jdobres.xxxx.com, request: "POST /main/login HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "jdobres.xxxxx.com", referrer: "http://jdobres.xxxx.com/"
UPDATE
I added the following into conf:
proxy_buffer_size 512k;
proxy_buffers 4 512k;
proxy_busy_buffers_size 512k;
And now I still get the following:
2012/12/16 12:40:27 [error] 31235#0: *929 upstream sent too big header while reading response header from upstream, client: 24.63.77.149, server: jdobres.xxxx.com, request: "POST /main/login HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "jdobres.xxxx.com", referrer: "http://jdobres.xxxx.com/"
I have proven that this is also sent when an invalid header is transmitted. Invalid characters or formatting of the HTTP headers, cookie expiration set back by more than a month, etc will all cause: upstream sent too big header while reading response header from upstream
I encountered this problem in the past (not using codeigniter but it happens whenever the responses contain a lot of header data) and got used to tweaking the buffers as suggested here, but recently I got bitten by this issue again and the buffers were apparently okay.
Turned out it was spdy's fault which I was using on this particular project and solved by enabling spdy headers compression like this:
Add this to your
http {}
of the nginx.conf file normally located at /etc/nginx/nginx.conf:Then add this to your php location block, this will be located in your vhost file look for the block that begins with location ~ .php$ {
using nginx + fcgiwrap + request too long
I had the same problem because I use a nginx + fcgiwrap configuration:
and the client was doing a request with a URL that was about 6000 characters (a bugzilla request).
debugging...
This is what I got in the logs:
can I have "414 request-uri too large" instead of "502 bad gateway"?
Yes you can! I was reading How to set the allowed url length for a nginx request (error code: 414, uri too large) before because I thought "hey the URL's too long" but I was getting
502
's rather than414
's.large_client_header_buffers
Try #1:
This fails, my URL is 6000 characters < 8k. Try #2:
Now I don't see a
502 Bad Gateway
anymore and instead I see a414 Request-URI Too Large
"upstream split a header line in FastCGI records"
Did some research and found somewhere on the internet:
This was sufficient for me:
Modify your nginx configuration and change/set the following directives: