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"