As oliver writes:
add_header
works as well withproxy_pass
as without.
However, as Shane writes, as of Nginx 1.7.5, you must pass always
in order to get add_header
to work for error responses, like so:
add_header X-Upstream $upstream_addr always;