Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to pass some custom header (ACCESS_TOKEN) from client RESTful application (JS) to application server (php-fpm).

I had read that nginx should pass all http headers to php, but somehow it does not come to my php :(

I can see it in firebug but can't see it in $_SERVER variable. it just does not exist in $_SERVER array.

I'm thinking that i need to pass it manually. Now my config looks like that:

location @php-fpm {
    include /etc/nginx/fastcgi_params;

    fastcgi_pass unix:/tmp/php5-fpm.sock;
    fastcgi_param REQUEST_URI    /index.php$request_uri;
    fastcgi_param SCRIPT_FILENAME /htdocs/index.php;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT /htdocs;

and when I add new line in location definition:

location @php-fpm {
    include /etc/nginx/fastcgi_params;
    fastcgi_param ACCESS_TOKEN $http_access_token;

or even if i will add it into fastcgi_params file it does not help :(

if I put into location part next line:

 fastcgi_param ACCESS_TOKEN $http_access_token;

then in php it has empty value :(

how I can pass custom header from client to backend (php) via nginx ?

share|improve this question

I see problem in that in custom header can't be used underscore. Instead of ACCESS_TOKEN I have to use ACCESS-TOKEN as header name, then nginx really passes it automatically.

And explanation how to fix had been found in this StackOverflow question.

share|improve this answer

Your Answer


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.