【问题标题】:Traefik authentication failedTraefik 认证失败
【发布时间】:2017-11-19 12:36:18
【问题描述】:

这是我的目标,我想在我的服务器上设置一个反向代理。我曾经使用 Haproxy 来完成这项工作,但我想尝试 Traefik。

首先我想获取 Traefik 的仪表板页面。它几乎可以工作,弹出窗口似乎输入了我的凭据,但即使我确定凭据正确,它也总是失败。

这是我的 traefik.toml

defaultEntryPoints = ["http", "https"]
# Web section is for the dashboard interface
[web]
address = ":8080"
[web.auth.basic]
  users = ["admin:aaa"]

# entryPoints section configures the addresses that Traefik and the proxied containers can listen on
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect] 
    entryPoint = "https"
[entryPoints.https]
address = ":443"
  [entryPoints.https.tls]

这是我运行容器的 docker 命令

docker run -d \
   -v /var/run/docker.sock:/var/run/docker.sock \
   -v $PWD/traefik.toml:/traefik.toml \
   -v $PWD/acme.json:/acme.json \
   -p 80:80 \
   -p 443:443 \
   -l traefik.frontend.rule=Host:monitor.firelabs.fr \
   -l traefik.port=8080 \
   --network proxy \
   --name traefik \
   traefik:1.3.6-alpine --docker --logLevel=DEBUG    

如您所见,我的凭据是 admin:aaa,每当我尝试将它们输入对话框时,它都会向我发送此消息:

time="2017-11-19T13:28:22Z" level=debug msg="Basic auth success..."

如您所见,这是一个非常基本的配置,仅用于开始使用 Traefik。所以我不知道我错在哪里,我查看了有关web部分配置的文档,它似乎没有错......

我错过了错字吗?

【问题讨论】:

    标签: docker traefik toml


    【解决方案1】:

    Traefik 将密码存储为 md5 哈希,而不是纯文本。你可以使用 htpasswd 来生成这个:

    $ htpasswd -nb admin aaa
    admin:$apr1$DWU.kdcZ$iqwGcFl9bfwp1WfKHE2yl.
    

    所以你的 traefik.toml 文件看起来像:

    [web.auth.basic]
    users = "admin:$apr1$DWU.kdcZ$iqwGcFl9bfwp1WfKHE2yl."
    

    【讨论】:

    • 感谢您的帮助,正如您所说,这是因为我使用了纯文本其他哈希!现在它完美运行!
    • 您可以使用在线工具:htaccesstools.com/htpasswd-generator 仅用于测试目的
    猜你喜欢
    • 1970-01-01
    • 2021-03-07
    • 2019-09-03
    • 2016-05-30
    • 2014-07-19
    • 2015-10-17
    • 2021-05-11
    • 2012-07-22
    • 2014-10-12
    相关资源
    最近更新 更多