如何解决Nginx 身份验证在根页面 (HTTPS) 上不起作用
我使用以下代码配置了 Nginx 身份验证,它显示了一些奇怪的行为。
.height
通过 https://$DOMAIN/ 访问根域时显示认证窗口,但登录时无法识别保存在 .htpasswd 文件中的用户。一旦我将应用程序放在另一个 URL (/axis1/在以下示例中),身份验证会突然生效。
在服务的端口后面添加斜杠时,身份验证也不起作用:
server {
listen 5000;
server_name localhost;
location / {
proxy_pass http://frp_server:4200;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
auth_basic "Administrator Area";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /axis1/ {
proxy_pass http://frp_server:4200;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
auth_basic "Administrator Area";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
更多信息:
- Nginx 代理将域 $SUBDOMAIN.$DOMAIN.com 指向 Nginx 脚本,因此可以通过 https://$SUBDOMAIN.$DOMAIN.com 访问网络服务器。此外,Nginx 运行在 Docker(与 Nginx-Proxy 相同的网络)中。
非常感谢任何帮助!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。