1

I have this web service that's running on nginx and fastcgi(php-fpm). The web service is used by some embeded http clients which will need to send some arbitrary http request headers when they are using the service. For example:

CLIENT_ID: client1
CLIENT_AUTH_TOKEN: d84ldx

or something like that.

I'm not sure if this kind of request will be captured by nginx when it arrives. If so, how would nginx store the values of the extra HTTP headers? And how to tell nginx to pass the parameters to php?

I have already tried to put

fastcgi_param CLIETN_ID $client_id 

into conf/fastcgi_params configuration file, I supposed this will help nginx to store what's in CLIENT_ID as the $client_id param. I also put

fastcgi_param CLIENT_ID $client_id

simply to fetch what's stored in $client_id and pass it to php as keyed 'CLIENT_ID', so php can access it with $_SERVER['CLIENT_ID'].

Unfortunately the above didn't work out. When I do

nginx -t 

I got the error "unknow parameter client_id". Where did I get it wrong and how to fix it?

Thank you.

2 Answers 2

5

Request headers are assigned variables starting with $http_, so a request header of Client-Id would be stored in $http_client_id. try

fastcgi_param CLIENT_ID $http_client_id;

I'm pretty sure that nginx already passes along all http headers, so it may already be available as $_SERVER['HTTP_CLIENT_ID']

0

Did you check if the headers are visible in the $_SERVER superglobal? I suspect this might "just work" without you having to do anything.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .