Duplicate Response Headers in NGINX Despite Using proxy_pass and rewrite break

I believe this problem has nothing to do with rewrite. You may have used add_header to output the response header, and this directive will unconditionally append a new header (even if the header with the same name exists upstream). Therefore, you may encounter the header with the same name because you used add_header to append this header while the header exists upstream. You can consider using proxy_hider_header and add_header together. The former can hide the header sent by the upstream. Of course, you can still get the value of the header through $upstream_http_xxx.