Traefik Dashboard returns always 404 in Docker Swarm deployment

Hi all,

I'm trying my best to get Traefik dashboard available through http://gateway.localhost/dashboard/, but I'm always getting a 404 response* from Traefik. Can s.o. please review my stack file and tell me, why it's not working?

I tried it on my server with a valid domain, but it's either working there or on localhost with Docker Desktop in Swarm mode.

docker stack deploy -c traefik.yml traefik

*404 is returned for these routes too: http://gateway.localhost, http://gateway.localhost/dashboard

traefik.yml:

version: '3'

services:
  reverse-proxy:
    image: traefik:v2.5
    command:
      - "--providers.docker.swarmmode=true"
      - "--providers.docker.exposedByDefault=false"
      - "--api.dashboard=true"
      - "--entrypoints.web.address=:80"
      # Logging
      - "--accesslog"
      - "--log.level=INFO"
    ports:
      - "80:80"
    deploy:
      labels:
        #Because Swarm API does not support automatic way
        - "traefik.http.services.reverse-proxy.loadbalancer.server.port=80"
        #Dashboard
        - "traefik.http.routers.dashboard.rule=Host(`gateway.localhost`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
        - "traefik.http.routers.dashboard.service=api@internal"
        - "traefik.http.routers.dashboard.entrypoints=web"
        - "traefik.http.routers.dashboard.middlewares=auth"
        - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
      placement:
        constraints:
          - node.role == manager
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

  whoami:
    image: traefik/whoami
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.whoami.rule=Host(`localhost`)"
        - "traefik.http.routers.whoami.entrypoints=web"
        - "traefik.http.services.whoami.loadbalancer.server.port=80"

same issue with traefik 2.8.1 :slight_smile:
version: '3'

services:
traefik-proxy:
image: traefik
command:
# Docker swarm configuration
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.swarmMode=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik-public"
# Configure entrypoint
- "--entrypoints.http-in.address=:80"
- "--entrypoints.https-in.address=:443"
# SSL configuration
- "--certificatesresolvers.letsencryptresolver.acme.httpchallenge=true"
- "--certificatesresolvers.letsencryptresolver.acme.httpchallenge.entrypoint=http-in"
- "--certificatesresolvers.letsencryptresolver.acme.email=hoang92bn@gmail.com"
- "--certificatesresolvers.letsencryptresolver.acme.storage=/letsencrypt/acme.json"
# Global HTTP -> HTTPS
- "--entrypoints.http-in.http.redirections.entryPoint.to=https-in"
- "--entrypoints.http-in.http.redirections.entryPoint.scheme=https"
# Enable dashboard
- "--api.dashboard=true"
- "--api=true"
- "--accesslog"
- "--log=true"
- "--log.filePath=/var/log/traefik.log"
- "--log.level=DEBUG"
ports:
- 80:80
- 443:443
volumes:
- /root/letsencrypt:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- traefik-public
deploy:
placement:
constraints:
- node.role == manager
labels:
- "traefik.http.services.reverse-proxy.loadbalancer.server.port=9999" #require by swarm
- "traefik.enable=true"
- "traefik.http.routers.traefik_https.rule=Host(traefik.thepdahoi.com) && (PathPrefix(/api) || PathPrefix(/dashboard))"
- "traefik.http.routers.traefik_https.tls=true"
- "traefik.http.routers.traefik_https.tls.certresolver=letsencryptresolver"
- "traefik.http.routers.traefik_https.entrypoints=https-in"
- "traefik.http.routers.traefik_https.service=api@internal"
- "traefik.http.routers.traefik_https.middlewares=traefik-auth"
- "traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$apr1$$bANmDVnw$$aJ3N9clCsjKDM9mnthnkG1"
networks:
traefik-public:
driver: overlay