Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

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']

share|improve this answer
add comment

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

share|improve this answer
    
nope, can't reload nginx due to the error. –  Shawn Apr 12 '11 at 1:49
    
Er, I meant without your extra nginx config settings. Also, try using: $http_client_id. See wiki.nginx.org/NginxHttpCoreModule#.24http_HEADER –  devicenull Apr 12 '11 at 1:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.