nginx passing back custom header

Solution 1:

You should use underscores_in_headers on directive which is off by default.

Solution 2:

You should use proxy_set_header for all headers you wish to forward to the backend servers. So instead of proxy_pass_header ... line:

proxy_set_header X_CUSTOM_HEADER $http_x_custom_header;

Solution 3:

The above didn't work for me either so I used proxy_pass_header. See the Nginx Wiki about proxy_pass_header here.

If your custom header is device_id add proxy_pass_header device_id; to your Proxy block.

If you are using customheaders with an underscore in it (like I am) be sure to make sure you have underscores_in_headers on in your Nginx Config.