nginx + cookies + firefox = 400 Bad Request

Jim Ohlstein jim.ohlstein at
Mon Dec 15 05:17:02 MSK 2008

It might be but I don't have that problem with my moderately busy vBulletin
board and 31% of my visitors (including myself) use Firefox. The difference
is that I use php-fcgi not Apache. Looking at Google search the problem
appears with other apps but the common denominator in most cases seems to be
when nginx is being used as a reverse proxy and only with Firefox. The
problem is more likely with Firefox than with vBulletin. As for number of
cookies, my browser has 11 from my vBulletin installation. The average user
has one fewer since they don't have an admin control panel cookie. In
contrast, I have 28 cookies from (which uses nginx to serve some of
the content that I browse), 30 from VerizonWireless (my cell phone company),
and 16 from American Express, so 11 (or 10 as a typical user might have)
does not seem "enormous".

Consider a brief test proxying your php requests to php-cgi (I use php-fpm
but you can use spawn-fcgi from lighttpd and you probably won't need to
recompile php for this test). There are lots of "recipes" online for doing
so. If the problem resolves then you can make a more informed decision. It
appears that the problem has existed in at least some versions of nginx
0.7.x - see
so a recompile may not help. I don't know if it's been rectified at that
site but I have visited it without issue. They are still using nginx but how
it is configured I do not know. If you decide to do this, also consider
running some benchmarks using a simple php script: Apache alone, nginx as
reverse proxy to Apache, nginx using fastcgi.

Good luck!


-----Original Message-----
From: owner-nginx at [mailto:owner-nginx at] On Behalf Of
Maxim Dounin
Sent: Sunday, December 14, 2008 7:57 PM
To: nginx at
Subject: Re: nginx + cookies + firefox = 400 Bad Request


On Sun, Dec 14, 2008 at 01:26:59PM +0100, Oliver Pestring wrote:

> Hi guys, this week is was about to move partially to nginx for all
> static content. The full switch was planned in about a month on a new
> server. I followed this guide
> and
> it worked instantly. After some minutes I got some t-calls about saying
> that the page isnt reachable with a 400 - Bad Request for them. It runs
> a vbulletin-forum and a Mantis-Bugtracker, it happens on both.
> Some hours later I could nail that problem down to nginx (same with 0.5x
> from etch and 0.632 from lenny) and firefox users (versions 2&3). It
> works again if the related domain-cookies are deleted. apache2 doesnt
> cause any trouble, same for IE/Opera-users.
> Tried a quick google search and I found endless posts on a lot of sites
> with the same 400 problem and ff after they switched to nginx (even
> famous ones like electronicarts). Sadly none if these contain a solution
> besides cleaning the cookies but that doesnt seem to help for long
> according to that posts.
> As I have over 60% FF-users Im a little afraid of the results and
> switched back to pure apache for the moment. Is there any known solution
> to this problem on serverside? May a selfcompiled-0.7-version help on
> this? Couldnt find anything related in the changelog.

You should tune large_client_header_buffers in your nginx config, see 
for details.

The problem AFAIK is vbulletin which sets enormous number of 
various cookies.

Maxim Dounin

More information about the nginx mailing list