phpnginxphp-5.5

Get headers with an underscore on NGINX


I have multiple apps in Google Play and App Store. These send custom request headers but these headers include an underscore e.g api_key.

The server has now moved from PHP 5.2 on Apache to PHP 5.5 on nginx. On NGINX, apache_request_headers() and getallheaders() are not available.

Is there any way to read custom request headers on NGINX server without having to go and update all apps to remove the underscore? Parsing the $_SERVER variable does not work either - any headers using and underscore are dropped.


Solution

  • You need to set underscores_in_headers on in your NGINX config.