nginx & php-fpm and custom header
Posted
by
nixer
on Server Fault
See other posts from Server Fault
or by nixer
Published on 2012-06-30T16:31:28Z
Indexed on
2012/07/01
9:17 UTC
Read the original article
Hit count: 280
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 ?
© Server Fault or respective owner