I am using nginx as a reverse proxy and trying to read a custom header from the response of an upstream server (Apache) without success. The Apache response is the following
I was facing the same issue. I tried both $http_my_custom_header
and $sent_http_my_custom_header
but it did not work for me.
Although solved this issue by using $upstream_http_my_custom_header
.
$http_name_of_the_header_key
i.e if you have origin = domain.com
in header, you can use $http_origin
to get "domain.com"
In nginx does support arbitrary request header field. In the above example last part of a variable name is the field name converted to lower case with dashes replaced by underscores
Reference doc here: http://nginx.org/en/docs/http/ngx_http_core_module.html#var_http_
For your example the variable would be $http_my_custom_header
.
Use $http_MY_CUSTOM_HEADER
You can write some-thing like
set my_header $http_MY_CUSTOM_HEADER;
if($my_header != 'some-value') {
#do some thing;
}