# Custom headers - Is it a bug or what?

**URL:** <https://www.ruby-forum.com/t/custom-headers-is-it-a-bug-or-what/214571>\
**Category:** NGINX\
**Created:** [December 6, 2011, 1:14am UTC](https://www.ruby-forum.com/t/custom-headers-is-it-a-bug-or-what/214571 "2011-12-06T01:14:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 6, 2011, 1:14am UTC](https://www.ruby-forum.com/t/custom-headers-is-it-a-bug-or-what/214571/1 "2011-12-06T01:14:21Z")

</div>

Hi everybody. I have a very simple question to what is possibly a bug.

In nginx 1.0.5, given the following nginx.conf:

* * *

server {  
server\_name myserver;

## location / { uwsgi\_pass 127.0.0.1:5001; uwsgi\_param HTTP\_MY\_CUSTOM\_HEADER $http\_my\_custom\_header; include uwsgi\_params; } }

Why does this works as expected…

$ curl -H “My-Custom-Header: Yes” [http://myserver/](http://myserver/)

…but this doesn’t.

$ curl -H “MY\_CUSTOM\_HEADER: Yes” [http://myserver/](http://myserver/)

In the latter case, the parameter is passed to my uwsgi application, but  
it’s just an empty string. I know HTTP headers are supposed to be  
case-insensitive, but nginx behavior is unexpected when the header  
doesn’t follow the usual format (title-cased, underscores instead of  
dashes).

Anyone had similar need to capture custom headers? Any nginx.conf  
examples?

Thanks.

---

<div class="post-metadata">

**Author:** ![Henrique\_Carvalho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c6cbf5/32.png) [@Henrique\_Carvalho\_A](https://www.ruby-forum.com/u/Henrique_Carvalho_A)\
**Post date:** [December 6, 2011, 1:18am UTC](https://www.ruby-forum.com/t/custom-headers-is-it-a-bug-or-what/214571/2 "2011-12-06T01:18:15Z")

</div>

Hello!

On Mon, Dec 05, 2011 at 10:13:47PM -0200, Henrique Carvalho Alves wrote:

> ```
> uwsgi_param HTTP_MY_CUSTOM_HEADER $http_my_custom_header;
> 
> ```
> 
> $ curl -H “MY\_CUSTOM\_HEADER: Yes” [http://myserver/](http://myserver/)
> 
> In the latter case, the parameter is passed to my uwsgi application, but it’s  
> just an empty string. I know HTTP headers are supposed to be case-insensitive,  
> but nginx behavior is unexpected when the header doesn’t follow the usual format  
> (title-cased, underscores instead of dashes).
> 
> Anyone had similar need to capture custom headers? Any nginx.conf examples?

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers)**
>
> This directive appeared in version 1.11.8.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Henrique\_Carvalho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c6cbf5/32.png) [@Henrique\_Carvalho\_A](https://www.ruby-forum.com/u/Henrique_Carvalho_A)\
**Post date:** [December 6, 2011, 9:02am UTC](https://www.ruby-forum.com/t/custom-headers-is-it-a-bug-or-what/214571/3 "2011-12-06T09:02:34Z")

</div>

On Mon, Dec 05, 2011 at 10:23:41PM -0200, Henrique Carvalho Alves wrote:

> > > * * *
> > > 
> > > Anyone had similar need to capture custom headers? Any nginx.conf examples?
> > 
> > [Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers)
> 
> I knew it should be something stupid. Thank you!

To expand on this, it’s actually subject to two directives, the  
above mentioned “underscores\_in\_headers”, and “ignore\_invalid\_headers”:

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers)**
>
> This directive appeared in version 1.11.8.

The default “underscores\_in\_headers on” marks headers with underscores  
as invalid (I’ve just updated the documentation to mention this), and  
default “ignore\_invalid\_headers on” ignores them. Currently nginx is  
too restrictive to the headers syntax, so some setups may require  
setting this directive to the value “off”.

---

<div class="post-metadata">

**Author:** ![Henrique\_Carvalho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c6cbf5/32.png) [@Henrique\_Carvalho\_A](https://www.ruby-forum.com/u/Henrique_Carvalho_A)\
**Post date:** [December 6, 2011, 1:24am UTC](https://www.ruby-forum.com/t/custom-headers-is-it-a-bug-or-what/214571/4 "2011-12-06T01:24:31Z")

</div>

Em 05/12/2011, s 22:17, Maxim D. escreveu:

> > server\_name myserver;
> 
> [Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers)

I knew it should be something stupid. Thank you!
