尝试访问 traefik 仪表板时出现 404

2024-02-12

我尝试以一种简单的方式通过子域访问 traefiktraefik (traefik.DOMAIN.com)。当我获得访问权限后,SSL 证书功能良好,但无法访问仪表板(404 错误)

docker-compose.yml

version: '3'

services:
  reverse-proxy:
    image: traefik:v2.2
    container_name: traefik
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - $PWD/traefik.toml:/etc/traefik/traefik.toml
      - $PWD/acme.json:/acme.json
    restart: always
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(`traefik.DOMAIN.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
      - "traefik.http.routers.api.service=api@internal"
      - "traefik.http.routers.api.entrypoints=websecure"
    networks:
      - web
networks:
  web:
    external: true

traefik.toml

[api]
  dashboard = true

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http]
      [entryPoints.web.http.redirections]
        [entryPoints.web.http.redirections.entryPoint]
          to = "websecure"
          scheme = "https"

  [entryPoints.websecure]
    address = ":443"
      [entryPoints.websecure.http.tls]
        certResolver = "default"

[providers]
  [providers.docker]
    watch = true
    exposedByDefault = false
    network = "web"

[certificatesResolvers]
  [certificatesResolvers.default]
    [certificatesResolvers.default.acme]
      email = "[email protected] /cdn-cgi/l/email-protection"
      storage = "acme.json"
      caServer = "https://acme-v01.api.letsencrypt.org/directory"
    [certificatesResolvers.default.acme.tlsChallenge]

关于如何实现这项工作有什么想法吗?我希望最终能够在子域上安装 owncloud


在阅读文档并在调试模式下检查日志后,我能够使其工作。这key这是尾随的/这是mandatory.

traefik.toml

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http]
      [entryPoints.web.http.redirections]
        [entryPoints.web.http.redirections.entryPoint]
          to = "websecure"
          scheme = "https"

  [entryPoints.websecure]
    address = ":443"
      [entryPoints.websecure.http.tls]
        certResolver = "default"


[providers]
  [providers.docker]
    watch = true
    exposedByDefault = false
    network = "web"


[log]
  level = "DEBUG"

[api]
  dashboard = true
  insecure = false

[accessLog]


[certificatesResolvers]
  [certificatesResolvers.default]
    [certificatesResolvers.default.acme]
      email = "[email protected] /cdn-cgi/l/email-protection"
      storage = "acme.json"
      caServer = "https://acme-v01.api.letsencrypt.org/directory"
    [certificatesResolvers.default.acme.tlsChallenge]

docker-compose.yaml

version: '3'

services:
  reverse-proxy:
    image: traefik:v2.2
    container_name: traefik
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - $PWD/traefik.toml:/etc/traefik/traefik.toml
      - $PWD/acme.json:/acme.json
    restart: always
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(`traefik.mydomain.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
      - "traefik.http.routers.api.service=api@internal"
      - "traefik.http.routers.api.entrypoints=websecure"
    networks:
      - web
networks:
  web:
    external: true

Files

ls
acme.json  docker-compose.yaml  traefik.toml
  • 现在考虑以下内容官方文档 https://doc.traefik.io/traefik/operations/dashboard/
curl -s -o /dev/null -w "%{http_code}" https://traefik.mydomain.com/dashboard/
200

curl -s -o /dev/null -w "%{http_code}" https://traefik.mydomain.com/dashboard
404

这是截图

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

尝试访问 traefik 仪表板时出现 404 的相关文章

随机推荐