NGINX set cookie based on value of a header
What kind of response are you getting? If there is an error in your response, you may need to add the always
flag or the header may not be added.
http://nginx.org/en/docs/http/ngx_http_headers_module.html
Syntax: add_header name value [always];
If the always parameter is specified (1.7.5), the header field will be added regardless of the response code