Howto to modify headers returned by proxied server

Hi all,

I am trying to create a reverse proxy towards various web-enabled
equipment.
Things are starting to work.

I run into the following problem:
Sometimes my some of web enabled equipment returns a request for basic
authentication. The header has a format which causes problems. Example:

WWW-Authenticate: Digest realm="…", domain="/", etc

I think the domain="/" causes the problem: Each of my web-enabled
equipment has its own location {} definition. I think the
domain="/" should either not be there or list domain="/. Nginx
forwards the header unchanged to the browser causing a basic
authentication prompt. I guess after that the browser sends the uid/pw
to nginx for url=/ (which does not lead back to the proper location
{} definition

How can I rewrite/modify this header?

kind regards
Paul S.