Traefik - 无法显示仪表板

Traefik - cannot show dashboard

Treafik 重定向非常有效!

如何配置要显示的 Traefik 仪表板

我有一个指向我的域的“A”记录和一个指向同一域的 CNAME 记录“monitor”。 这是正确的吗?

我的第一次尝试是 docker-compose.yml file。它还包含一个 Spring 侦听 8080 的引导应用程序:

version: '3'
services:
  traefik:
    image: traefik:latest
    container_name: traefik
    command: --api --docker
    restart: always
    networks:
      - geosolutionsnet
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/ec2-user/traefik/traefik.toml:/traefik.toml
      - /home/ec2-user/traefik/acme.json:/acme.json
    ports:
      - "80:80"
      - "443:443"
    labels:
      - "traefik.docker.network=geosolutionsnet"
      - "traefik.enable=true"
      - "traefik.frontend.rule=Host:monitor.xyz.nl"
      - "traefik.port=8080"
      - "traefik.protocol=http"
      #- "traefik.frontend.headers.STSSeconds=15768000"

我用浏览器指向 'monitor.xyz.nl' 但我得到了 404。

我的第二次尝试是:

      - "traefik.frontend.rule=Host:xyz.nl;Path:/monitor"

将我的浏览器指向 xyz。nl/monitor ... 再次出现 404。

我的 traefik.toml 文件是:

defaultEntryPoints = ["http", "https"]
[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
    address = ":443"
    [entryPoints.https.tls]
    
[docker]
  endpoint = "unix:///var/run/docker.sock"
  domain = "xyz.nl"
  watch = true
  exposedByDefault = false
  
[acme]
  email = "jj@xyz.nl"
  storage = "acme.json"
  onHostRule = true
  entryPoint = "https"
  onDemand = false
  [acme.tlsChallenge]

更新: 使用映射到域 xyz.nl/traefik 的 CNAME traefik 会导致 404 错误。

使用 CNAME 'monitor' 指向(A 记录)域,我得到了相同的结果。我认为这是正常的,因为我通过路径前缀配置了主机匹配。

docker-compose.yml

services:
  traefik:
    image: traefik:latest
    container_name: traefik
    restart: always
    networks:
      - geosolutionsnet
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/ec2-user/traefik/traefik.toml:/traefik.toml
      - /home/ec2-user/traefik/acme.json:/acme.json
    ports:
      - "80:80"
      - "443:443"
    labels:
      - "traefik.docker.network=geosolutionsnet"
      - "traefik.enable=true"
      - "traefik.frontend.rule=Host:xyz.nl;PathPrefix:/monitor" # <----
      - "traefik.port=8080"

treafik.toml

defaultEntryPoints = ["http", "https"]
[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
    address = ":443"
    [entryPoints.https.tls]

[api]

[docker]
  domain = "xyz.nl"
  exposedByDefault = false

[acme]
  email = "jj@xyz.nl"
  storage = "acme.json"
  onHostRule = true
  entryPoint = "https"
  onDemand = false
  [acme.tlsChallenge]

我建议不要在同一部分混合使用 CLI 参数和 TOML(例如:--docker[docker]

在 Docker compose 中,我添加到 traefik 部分端口 8080:8080。

然后,通过导航到端口 8080 显示 Traefik 仪表板。重要的是通过 'http' 和 NOT 'https' 导航。

下一个改进是使用 HTTPS,这样任何不友好的人都无法访问 Traefik 仪表板。