nginx proxy_pass 代理不透传 basic auth 到后端

创建日期: 2022-11-05 09:13 | 作者: 风波 | 浏览次数: 11 | 分类: Nginx

使用 nginx 进行 proxy_pass 代理时,如果在前面设置了 proxy_pass 后,那么这个代理貌似会自动透传到后面的服务中。这样会导致一个问题,就是在浏览器执行 XHR 的时候,会再次要求输入 basic auth 的认证信息。但这是不必要的。

下面配置可以取消 basic auth 向后面服务的透传:

adding the below in the location block to tell nginx not to send authorization to the upstream

proxy_set_header Authorization "";

参考:https://stackoverflow.com/questions/48591660/reverse-proxy-with-nginx-basic-authentication-on-the-proxy-but-not-to-the-back

11 浏览
0 评论