【问题标题】:Unable to bypass basic authentication for a particular URL in Nginx无法绕过 Nginx 中特定 URL 的基本身份验证
【发布时间】:2019-01-26 01:10:09
【问题描述】:

我已阅读并尝试了类似帖子中提到的几乎所有步骤/选项。 这是我的 Nginx 文件的样子:

location / {
        proxy_pass    http://localhost:8000;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }

我正在尝试从基本身份验证中排除以下部分:

/engine/v1/状态

到目前为止,我已经尝试了以下方法:

location **/engine/v1/status** {
            **auth_basic "off"**;
            allow all; # Allow all to see content 

}

location **= /engine/v1/status** {
            **auth_basic off;**
            allow all; # Allow all to see content 

}

location **= /engine/v1/status** {
            **auth_basic "off";**
            allow all; # Allow all to see content 

}

我还是得到了一个

HTTP 401: Unauthorized 您配置了一个侦听器规则来进行身份验证 用户。您将 OnUnauthenticatedRequest 配置为拒绝 未经身份验证的用户或 IdP 拒绝访问

在我的 AWS 目标组上 我在这里做错了什么?

【问题讨论】:

  • 我认为**s 只是噪音。 off 是关键字而不是字符串,因此不应被引用。如果该位置打算反向代理上游,它也需要一个proxy_pass 语句。
  • @RichardSmith 谢谢你的建议。我能够达到预期的结果。

标签: amazon-web-services nginx amazon-elb nginx-location


【解决方案1】:

这就是我能够做到的。

location = /engine/v1/status {
                proxy_pass    http://localhost:8000;
                auth_basic off;
                allow all; # Allow all to see content      
        }

【讨论】:

    猜你喜欢
    • 2012-01-03
    • 2017-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 2020-03-29
    • 2020-10-22
    • 1970-01-01
    相关资源
    最近更新 更多