[Need Help] Traefik + Docker Swarm

Hello,

I hope you are doing well.

I need some help because the documentation is far too unclear for me. I tried to configure Traefik with Docker Swarm to access the dashboard via 0.0.0.0/dashboard/, but I keep getting a 404 not found.
Here is my Docker Compose configuration for Traefik:

docker-compose.yml

services:
####### Traefik #######
  reverse-proxy:
    image: traefik:latest
    command:
      # ————————— Dashboard ————————— #
      - --api=true

      # —————— Provider Docker —————— #
      - --providers.swarm.exposedByDefault=false
      - --providers.swarm.endpoint=unix:///var/run/docker.sock

      # ———————— Entrypoint ————————— #
      - --entrypoints.web.address=:80
    ports:
      - target: 80
        published: 80
        mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - proxy-network
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.dashboard.rule=Host(`0.0.0.0`)"
      - "traefik.http.routers.dashboard.service=api@internal"
      - "traefik.http.routers.dashboard.middlewares=auth"
      - "traefik.http.middlewares.auth.basicauth.users=admin:$$2y$$10$$1t34DNgXSMiNlZEtNSGFuO65fc37tPuqD6av5Px6YZIj9aFBd.DTW"
#######################

##### SWARM NETWORK #####
networks:
  proxy-network:
    driver: overlay
    attachable: true
#########################

docker swarm init
docker stack deploy -c docker-compose.yml traefik

Hello,
I struggle also a bit. I see you labels is not well configured should be under deploy
Here is my config :

version: "3.3"

services:
  traefik:
    environment:
      - TZ=Europe/Paris
    image: "traefik:latest"
    command: # Static traefik config
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.swarm=true
      - --api=true
      - --accesslog=true  
      - --providers.swarm.exposedbydefault=false
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    deploy:
      labels:
        - "traefik.enable=true"
        #Traefik Router Setup
        - "traefik.http.routers.dashboard.rule=Host(`traefik.domain.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
        - "traefik.http.routers.dashboard.service=api@internal"
        - "traefik.http.routers.dashboard.middlewares=auth"
        - "traefik.http.middlewares.auth.basicauth.users=admin:****"
        - "traefik.http.services.dummy-svc.loadbalancer.server.port=9999"
      restart_policy:
        condition: any
      placement:
        constraints: [node.role == manager]

for the admin password on a linux with htpasswd installed run :
htpasswd -c /tmp/password admin

This will generate a has that you can place in the stack file.

Check simple Traefik Swarm example.

Note that you can not access a service at 0.0.0.0. That address is only a placeholder for a service to "listen to all available IPs". But when accessing a service from a client/browser, you need to use a real IP address.

And as stated before, the labels for Traefik Swarm services need to go into the deploy section.