# Nginx returning 414 even when large\_client\_header\_buffers is set

**URL:** <https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717>\
**Category:** NGINX\
**Created:** [April 10, 2012, 3:29am UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717 "2012-04-10T03:29:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [April 10, 2012, 3:29am UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/1 "2012-04-10T03:29:10Z")

</div>

My nginx server needs a request whose URI is about 4k long, it currently  
returns 414 with message Request-URI Too Long.

I looked online and added:

large\_client\_header\_buffers 4 16k;

to the http block in nginx.conf, restarted nginx, still returns 414.

I also tried to add client\_header\_buffer\_size and set to 16k and well  
but didn’t help.

I have nginx 1.0.12 and built with the following options:

“–with-http\_ssl\_module”,  
“–with-http\_gzip\_static\_module”,  
“–add-module=…/git/nginx-x-rid-header”,  
“–with-ld-opt=-luuid”,  
“–with-http\_stub\_status\_module”

Anybody has any insights on the 414 problem?

Posted at Nginx Forum:

> **[Nginx returning 414 even when large\_client\_header\_buffers is set](https://forum.nginx.org/read.php?2,225093,225093#msg-225093)**
>
> My nginx server needs a request whose URI is about 4k long, it currently returns 414 with message Request-URI Too Long. I looked online and added: large\_client\_header\_buffers 4 16k; to the http block in nginx.conf, restarted nginx, still returns 414....

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [April 10, 2012, 10:04pm UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/2 "2012-04-10T22:04:17Z")

</div>

It appears that no matter how big I set the value of  
large\_client\_header\_buffers to be, nginx just doesn’t care of the  
setting and still returns 414 on a long request.

I tried to make it 16k, 32k, 256k, and 512k, etc and POSTing a request  
with 1.5k long URL returns 414. It works when I reduce the request URI  
length to about 1k, regardless of the large\_client\_header\_buffers value  
as well.

I also tried to set proxy\_buffers to a large value and didn’t help.

Is there any other settings I need to look at to make the nginx box take  
longer request URI without returning 414?

Posted at Nginx Forum:

> **[Re: Nginx returning 414 even when large\_client\_header\_buffers is set](https://forum.nginx.org/read.php?2,225093,225135#msg-225135)**
>
> My nginx server needs a request whose URI is about 4k long, it currently returns 414 with message Request-URI Too Long. I looked online and added: large\_client\_header\_buffers 4 16k; to the http block in nginx.conf, restarted nginx, still returns 414....

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [April 10, 2012, 10:26pm UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/3 "2012-04-10T22:26:38Z")

</div>

> You have to configure  
> client\_header\_buffer\_size/large\_client\_header\_buff  
> ers  
> in a default server (or at http level).

I tried to set it in the http context of the main /etc/nginx/nginx.conf  
file:

http {  
large\_client\_header\_buffers 8 512k;

…  
include /etc/nginx/sites-enabled/\*;  
}

And my server contexts are defined in a conf file in sites-enabled. But  
large\_client\_header\_buffers still appears to be ignored.

Posted at Nginx Forum:

> **[Re: Nginx returning 414 even when large\_client\_header\_buffers is set](https://forum.nginx.org/read.php?2,225093,225138#msg-225138)**
>
> My nginx server needs a request whose URI is about 4k long, it currently returns 414 with message Request-URI Too Long. I looked online and added: large\_client\_header\_buffers 4 16k; to the http block in nginx.conf, restarted nginx, still returns 414....

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [April 10, 2012, 10:10pm UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/4 "2012-04-10T22:10:31Z")

</div>

Hello!

On Tue, Apr 10, 2012 at 04:03:50PM -0400, spacerobot wrote:

> Is there any other settings I need to look at to make the nginx box take  
> longer request URI without returning 414?

Most likely you are trying to configure  
client\_header\_buffer\_size/large\_client\_header\_buffers in a pure  
virtual server{}. This won’t work as request headers parsing  
happens before Host header is known (and virtual server is  
selected), hence parseing happens in a context of the default  
server for a listen socket.

You have to configure  
client\_header\_buffer\_size/large\_client\_header\_buffers  
in a default server (or at http level).

Maxim D.

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [April 11, 2012, 9:21am UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/5 "2012-04-11T09:21:14Z")

</div>

Hello!

On Tue, Apr 10, 2012 at 07:45:21PM -0400, spacerobot wrote:

> > > headers parsing  
> > > client\_header\_buffer\_size/large\_client\_header\_buff
> 
> simplest configuration possible, as below.  
> worker\_connections 2048;
> 
> ```
> set $foo "foo.com";
> 
> location / {
> proxy_set_header x-foo-rid $request_id;
> proxy_redirect http://$foo /;
> proxy_pass http://$foo;
> }
> 
> ```
> 
> }  
> }

Are you sure the error is returned by this nginx instance, not by  
your http backends?

Maxim D.

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [April 12, 2012, 1:09am UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/6 "2012-04-12T01:09:18Z")

</div>

> Are you sure the error is returned by this nginx  
> instance, not by  
> your http backends?
> 
> Maxim D.

Oh Thank you! It was from unicorn, not nginx. Everything began to make  
sense then. 😃

Posted at Nginx Forum:

> **[Re: Nginx returning 414 even when large\_client\_header\_buffers is set](https://forum.nginx.org/read.php?2,225093,225193#msg-225193)**
>
> My nginx server needs a request whose URI is about 4k long, it currently returns 414 with message Request-URI Too Long. I looked online and added: large\_client\_header\_buffers 4 16k; to the http block in nginx.conf, restarted nginx, still returns 414....

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [April 11, 2012, 1:45am UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/7 "2012-04-11T01:45:41Z")

</div>

Hello,

## spacerobot Wrote:

> > selected), hence parseing happens in a context
> 
> And my server contexts are defined in a conf file  
> in sites-enabled. But large\_client\_header\_buffers  
> still appears to be ignored.

I further tried the following things, which didn’t help either:

- took out most of the configs in my nginx.conf and now I have the  
simplest configuration possible, as below.
- upgraded to 1.0.14 stable from 1.0.12 development.

My new simplified nginx.conf:

worker\_processes 2;  
daemon off;

error\_log /var/log/nginx/error.log;

events {  
worker\_connections 2048;  
}

http {  
client\_header\_buffer\_size 256k;  
large\_client\_header\_buffers 8 1024k;

upstream [foo.com](http://foo.com) {  
server 10.0.0.99:16234;  
server 10.0.0.20:16234;  
}

server {  
listen 443;

```
ssl on;
ssl_certificate /etc/foo.com.crt;
ssl_certificate_key /etc//foo.com.key;

server_name foo;

access_log /var/log/nginx/access.log main;

set $foo "foo.com";

location / {
  proxy_set_header x-foo-rid $request_id;
  proxy_redirect http://$foo /;
  proxy_pass http://$foo;
}

```

}  
}

Posted at Nginx Forum:

> **[Re: Nginx returning 414 even when large\_client\_header\_buffers is set](https://forum.nginx.org/read.php?2,225093,225146#msg-225146)**
>
> My nginx server needs a request whose URI is about 4k long, it currently returns 414 with message Request-URI Too Long. I looked online and added: large\_client\_header\_buffers 4 16k; to the http block in nginx.conf, restarted nginx, still returns 414....

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [November 11, 2015, 6:37pm UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/8 "2015-11-11T18:37:29Z")

</div>

I changed the request from a get to a post in order to get it working  
for my site.

---

<div class="post-metadata">

**Author:** ![spacerobot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@spacerobot](https://www.ruby-forum.com/u/spacerobot)\
**Post date:** [February 11, 2014, 6:23pm UTC](https://www.ruby-forum.com/t/nginx-returning-414-even-when-large-client-header-buffers-is-set/218717/9 "2014-02-11T18:23:30Z")

</div>

Hi spacerobot,

I am encountering a very similar problem with my nginx/unicorn server  
with  
an 11k URI, getting error “HTTP/1.1 414 Request-URI Too Long”.

We have also modified the nginx.conf httpd context to include:  
client\_header\_buffer\_size 32k;  
large\_client\_header\_buffers 16 512k;  
Which in theory should be more than sufficient to handle this URI…

Could you please give some more information on what you’ve modified with  
Unicorn to allow a larger URI?  
Thanks!

Posted at Nginx Forum:

> **[Re: Nginx returning 414 even when large\_client\_header\_buffers is set](https://forum.nginx.org/read.php?2,225093,247422#msg-247422)**
>
> My nginx server needs a request whose URI is about 4k long, it currently returns 414 with message Request-URI Too Long. I looked online and added: large\_client\_header\_buffers 4 16k; to the http block in nginx.conf, restarted nginx, still returns 414....
