large_client_header_buffers: Custom error pages are not working

prajos nginx-forum at
Tue Jun 5 09:34:10 UTC 2018

Hi there,
I'm using nginx nginx version 1.12.0 as a reverse proxy to my application
I allow certain top level checks like header size and count to be done at
nginx level.

The server block looks like the following:

server {
listen            443 ssl default_server;
large_client_header_buffers 32 512;
  location / {

   error_page 400 /400.json;
   location = /400.json {
	root /etc/nginx/errors-files/;
	allow all;


Then I start testing the nginx with curl and adding a header of size 600
nginx promptly stops the request and dumps a default error page instead of
my custom error page.

<head><title>400 Request Header Or Cookie Too Large</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>Request Header Or Cookie Too Large</center>

How can I get a CUSTOM ERROR page for this situation working instead of the
default page.

Posted at Nginx Forum:,280035,280035#msg-280035

More information about the nginx mailing list