【发布时间】:2021-11-17 08:51:57
【问题描述】:
我在 nginx 网络服务器后面有 Wildfly 24,充当具有基本身份验证的反向代理。当我使用 Insomnia 访问我的服务时,我可以发送一个 POST(并且有效),但问题是 request.getRemoteUser() 返回 NULL,而不是来自基本身份验证的经过身份验证的用户,我需要在我的应用程序中使用该值。
这是我的 nginx 配置
location / {
auth_basic "Application auth";
auth_basic_user_file /etc/nginx/htpasswd;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://wildfly/;
include snippets/services.conf;
return 404;
}
其中snippets/services.conf 仅出于遗留原因包含大量重写。
我已经尝试添加proxy_set_header Authorization $http_authorization; 和proxy_pass_header Authorization;,但到目前为止还没有产生任何结果。有什么我想念的想法吗?
【问题讨论】:
标签: nginx http-post wildfly reverse-proxy basic-authentication