Send additional header to FastCGI backend with nginx

Dynalon picture Dynalon · Feb 27, 2012 · Viewed 26.5k times · Source

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.

Answer

Kamu picture Kamu · Feb 27, 2012

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