【发布时间】:2018-07-25 01:05:34
【问题描述】:
当子请求发送到 nginx auth_request 模块时,我收到以下错误。 作为信息,我开发了一个基于 Spring Security 的 Web 应用程序,它只包含一个 Web 方法,即进行身份验证以验证用户凭据和会话,并以 200 或 401 错误代码响应。
认证成功后页面被重定向到显示上游应用程序主页的主页 url,而不是我在 nginx 日志中收到此错误,如下所示
错误 身份验证请求意外状态:404,同时发送到客户端,客户端:127.0.0.1,服务器:,请求:“GET / HTTP/1.1”,主机:“localhost:8180”,引用者:“https://localhost:8180/login.html”*
此错误表明 nginx 已将完整请求的 url 传递给 auth subrequest 而不是“/authenticate”,并且 auth 服务会查找它在其中找不到的资源并抛出 404 错误。
server {
listen 8180 ssl;
ssl_certificate certs/nginx.pem;
ssl_certificate_key certs/nginx.pem;
location /{
proxy_set_header xclnt "ap1";
auth_request /authenticate;
proxy_pass https://adi-backend;
}
location = /authenticate {
proxy_set_header xclnt "ap1";
proxy_pass http://authserv;
}
location = /login.html {
root html;
}
location = /50x.html {
root html;
}
error_page 500 502 503 504 /50x.html;
error_page 401 403 login.html;
}
【问题讨论】:
标签: authentication nginx runtime-error http-status-code-404