Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send additional header to FastCGI backend with nginx

I use nginx with several fastcgi backends (php-cgi, mod-mono-fastcgi4). Now I need to sent an additional http header to the fastcgi backend, basically the same as proxy_set_header does when using nginx as reverse proxy. But to my findings, there is no such thing as fastcgi_set_header in nginx.

Somebody got any ideas how to do this anyways? I dont want to use additional nginx modules as the solution muste be easily deployable on a wide range of customer systems.

like image 508
Dynalon Avatar asked Feb 27 '12 12:02

Dynalon


People also ask

Does Nginx pass headers?

By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client.

What is add header in Nginx?

The Nginx add_header directive allows you to define an arbitrary response header and value to be included in all response codes, which are equal to 200 , 201 , 204 , 206 , 301 , 302 , 303 , 304 , or 307 . This can be defined from within your nginx.


1 Answers

I took a quick look at the manual and I think the closest you will find is passing fastcgi parameters:

The request headers are transferred to the FastCGI-server in the form of parameters. In the applications and the scripts run from the FastCGI-server, these parameters are usually accessible in the form of environment variables. For example, the header "User-agent" is transferred as parameter HTTP_USER_AGENT. Besides the headers of the HTTP request, it is possible to transfer arbitrary parameters with the aid of directive fastcgi_param.

http://wiki.nginx.org/HttpFcgiModule#Parameters.2C_transferred_to_FastCGI-server.

fastcgi_param

syntax: fastcgi_param parameter value

http://wiki.nginx.org/HttpFcgiModule#fastcgi_param

like image 158
Kamu Avatar answered Sep 17 '22 06:09

Kamu