【问题标题】:Unable to access website after setting up basic-auth in haproxy在 haproxy 中设置基本身份验证后无法访问网站
【发布时间】:2018-09-27 08:43:57
【问题描述】:

我正在尝试在我的 kibana 服务前面设置基本身份验证,该服务在 https 上运行。从我从文档和其他在线资源中了解到,我需要创建一个具有凭据的用户列表。这是我做过的。在前端部分,我创建了 2 个 ACL,其中一个检查使用 http_auth 来验证凭据(或者我被引导相信)。然后我说如果两个 ACL 要求都满足(即正确的地址和正确的凭据),则使用正确的服务器。

运行curl -u admin:terriblePassw0rd https://example.com 我得到一个 404。我非常感谢任何关于修复什么或进一步查看的指针或指南。

感谢您的宝贵时间。

userlist userAuth
    user admin insecure-password terriblePassw0rd

frontend default-frontend-hpp
    bind :80
    http-request redirect location https://example.com code 302 if { hdr_dom(host) -i example.com }

frontend default-frontend-https
    bind :443 ssl crt /path/to/cert/example.pem
    reqadd X-Forwarded-Proto:\ https

    acl auth_check http_auth(userAuth)
    acl example hdr(host) -i example.com
    use_backend example-backend if example auth_check

backend example-backend
    server name IP:port check

【问题讨论】:

  • 我最终找到的解决方案是将auth check移到后端。所以它现在看起来像:``backend example-backend acl auth_check http_auth(userAuth) http-request auth realm servername unless auth_check server name IP:port check`

标签: proxy kibana reverse-proxy haproxy


【解决方案1】:

既然是404 而不是503,那么基本身份验证应该可以工作。

但你可能想改变

acl auth_check http_auth(userAuth)
acl example hdr(host) -i example.com
use_backend example-backend if example auth_check

acl auth_check http_auth(userAuth)
http-request deny unless auth_check
acl example hdr(host) -i example.com
use_backend example-backend if example

这样,如果您没有提供正确的用户/密码,您会得到403,如果身份验证失败,您会得到503

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-04
    • 2016-02-25
    • 2015-11-30
    • 1970-01-01
    • 2013-05-31
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多