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 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 http://o7.no/N6DM7q 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

1 Answer 1

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

 
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.