# Nginx FastCGI question

**URL:** <https://www.ruby-forum.com/t/nginx-fastcgi-question/229450>\
**Category:** NGINX\
**Created:** [January 1, 2013, 7:21pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-question/229450 "2013-01-01T19:21:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![newdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/aca169/32.png) [@newdude](https://www.ruby-forum.com/u/newdude)\
**Post date:** [January 1, 2013, 7:21pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-question/229450/1 "2013-01-01T19:21:40Z")

</div>

Hi,

When you run a FastCGI application behind Nginx does Nginx pass all the  
HTTP request headers to the FastCGI server / app? Or do you need to  
explicitly pass them using fastcgi\_param?

If Nginx does pass them, does it pass them all or only a subset of the  
request headers? The FastCGI specification is not at all clear on  
whether the HTTP headers are passed or not.

Also in the same way I’ve read through the FastCGI specification and can  
find no information in which states which entity is responsible for  
generating all the HTTP response headers. I would assume it would be my  
FastCGI app and Nginx just forwards it on but does Nginx add or modify  
any headers after I have sent my response from my FastCGI app back to  
Nginx?

Thanks.

---

<div class="post-metadata">

**Author:** ![newdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/aca169/32.png) [@newdude](https://www.ruby-forum.com/u/newdude)\
**Post date:** [January 2, 2013, 6:37am UTC](https://www.ruby-forum.com/t/nginx-fastcgi-question/229450/2 "2013-01-02T06:37:29Z")

</div>

In addition to what Maxim said some people do not realize that not all  
headers are created equally and that something as inane as underscores  
versus dashes causes it to break RFC and nginx need you to explicitly  
tell  
it that that’s okay:  
[http://nginx.org/en/docs/http/ngx\_http\_core\_module.html#underscores\_in\_headers](http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers)

Posted at Nginx Forum:

> **[Re: Nginx FastCGI question](https://forum.nginx.org/read.php?2,234608,234616#msg-234616)**
>
> Hi, When you run a FastCGI application behind Nginx does Nginx pass all the HTTP request headers to the FastCGI server / app? Or do you need to explicitly pass them using fastcgi\_param? If Nginx does pass them, does it pass them all or only a subset...

---

<div class="post-metadata">

**Author:** ![newdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/aca169/32.png) [@newdude](https://www.ruby-forum.com/u/newdude)\
**Post date:** [January 2, 2013, 9:14am UTC](https://www.ruby-forum.com/t/nginx-fastcgi-question/229450/3 "2013-01-02T09:14:38Z")

</div>

On 01/01/13 20:45, Maxim D. wrote:

> > If Nginx does pass them, does it pass them all or only a subset of  
> > would be my FastCGI app and Nginx just forwards it on but does Nginx  
> > it’s needed.

Thanks for that. The CGI RFC certainly seems more useful than the  
FastCGI specification.

---

<div class="post-metadata">

**Author:** ![newdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/aca169/32.png) [@newdude](https://www.ruby-forum.com/u/newdude)\
**Post date:** [January 2, 2013, 9:15am UTC](https://www.ruby-forum.com/t/nginx-fastcgi-question/229450/4 "2013-01-02T09:15:13Z")

</div>

On 02/01/13 05:36, Ensiferous wrote:

> In addition to what Maxim said some people do not realize that not all  
> headers are created equally and that something as inane as underscores  
> versus dashes causes it to break RFC and nginx need you to explicitly tell  
> it that that’s okay:  
> [Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers)

I’ll bear that in mind. Thanks.

---

<div class="post-metadata">

**Author:** ![newdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/aca169/32.png) [@newdude](https://www.ruby-forum.com/u/newdude)\
**Post date:** [January 1, 2013, 9:45pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-question/229450/5 "2013-01-01T21:45:58Z")

</div>

Hello!

On Tue, Jan 01, 2013 at 06:21:02PM +0000, Some D. wrote:

> Hi,
> 
> When you run a FastCGI application behind Nginx does Nginx pass all  
> the HTTP request headers to the FastCGI server / app? Or do you need  
> to explicitly pass them using fastcgi\_param?
> 
> If Nginx does pass them, does it pass them all or only a subset of  
> the request headers? The FastCGI specification is not at all clear  
> on whether the HTTP headers are passed or not.

All HTTP request headers are passed to a FastCGI application by  
default. You may modify/clear some by using the fastcgi\_param  
directive.

> Also in the same way I’ve read through the FastCGI specification and  
> can find no information in which states which entity is responsible  
> for generating all the HTTP response headers. I would assume it  
> would be my FastCGI app and Nginx just forwards it on but does Nginx  
> add or modify any headers after I have sent my response from my  
> FastCGI app back to Nginx?

FastCGI relies on CGI here, so you should read RFC 3875 for basics,  
see [RFC 3875: The Common Gateway Interface (CGI) Version 1.1 | RFC Editor](http://tools.ietf.org/html/rfc3875#section-6). In short - you  
are responsible for headers like “Content-Type”, but must not add  
headers like “Transfer-Encoding”.

Response from a FastCGI backend is treated by nginx more or less  
like any other response, so response headers will be modified if  
it’s needed.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
