我正在尝试使用 nginx 基本身份验证来保护我的 web 应用程序。
我正在寻找的是一种强制浏览器显示我的自定义 html 登录页面而不是默认登录弹出窗口但仍处理授权过程的方法。
我尝试省略“WWW-Authenticate”标头,但未显示弹出窗口,但我不知道如何强制浏览器为每个请求添加“授权”标头。
特此 nginx.conf:
location /{
auth_basic "Restricted";
auth_basic_user_file htpasswd;
proxy_pass http://tomcat:8080/;
error_page 401 /login.html;
}
location = /login.html {
root html;
more_clear_headers 'WWW-Authenticate';
}
Run Code Online (Sandbox Code Playgroud) nginx ×1