Forum: NGINX Nginx FastCGI question

Posted by Some Developer (Guest)
on 2013-01-01 19:21
(Received via mailing list)
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.
Posted by Maxim Dounin (Guest)
on 2013-01-01 21:45
(Received via mailing list)
Hello!

On Tue, Jan 01, 2013 at 06:21:02PM +0000, Some Developer 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 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 Dounin
http://nginx.com/support.html
Posted by Ensiferous (Guest)
on 2013-01-02 06:37
(Received via mailing list)
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...

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,234608,234616#msg-234616
Posted by Some Developer (Guest)
on 2013-01-02 09:14
(Received via mailing list)
On 01/01/13 20:45, Maxim Dounin 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.
Posted by Some Developer (Guest)
on 2013-01-02 09:15
(Received via mailing list)
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:
> http://nginx.org/en/docs/http/ngx_http_core_module...

I'll bear that in mind. Thanks.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.