【问题标题】:Traefik basic auth does not work with HTTPSTraefik 基本身份验证不适用于 HTTPS
【发布时间】:2017-11-23 12:07:12
【问题描述】:

我使用以下标签在 Docker 暖模式下运行服务:

- "traefik.docker.network=proxy"
- "traefik.backend=kibana"
- "traefik.frontend.entryPoints=https,http"
- "traefik.frontend.rule=Host:mydomain"
- "traefik.port=5601"
- "traefik.frontend.auth.basic=test:098f6bcd4621d373cade4e832627b4f6"

使用 HTTPS 遇到这个问题

curl -u test:test https://my-domain.com
401 Unauthorized

使用 HTTP 一切正常

curl -u test:test http://my-domain.com
Found

【问题讨论】:

    标签: traefik


    【解决方案1】:

    使用htpassword 为我解决了这个问题。 Traefik 似乎使用相同的算法来取消密码。

    apt install apache2-utils
    
    htpasswd -nb your_username "your_password_here"
    

    您将收到相应的哈希

    your_username:khrglahfslgkha345346
    

    将其复制粘贴到您的 .toml 或 docker-compose 脚本中。

    使用您的密码(而不是哈希)在您的前端登录,一切都会正常工作。

    【讨论】:

      【解决方案2】:

      我最近发现您必须注意生成的hash 中的双美元符号。你必须在不同的情况下逃避$....

      【讨论】:

        【解决方案3】:

        我找到了问题的原因,我将服务部署为带有 traefik 变量 "traefik.frontend.auth.basic=test:$$apr1$$EaOXV0L6$DQbzuXBeb6Y8jjI2ZbGsg/" 的堆栈。但是在部署后这个变量的值看起来像test:/

        手动设置正确值后 - 身份验证工作正常。

        我还尝试使用命令 docker service create 部署服务,并且变量具有正确的值。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-04-30
          • 1970-01-01
          • 2018-04-19
          • 2021-11-15
          • 2021-01-13
          相关资源
          最近更新 更多