Configuring Docker Swarm mode and secured dashboard results to 404 error

After reading documentation and some blog posts I created simple traefik configuration and deployed it to docker swarm mode:

cat traefik-simple.yaml

version: '3.6'

services:
  reverse-proxy:
    image: traefik:v2.0.2
    command:
      - "--log.level=DEBUG"
      - "--accesslog=true"
      - "--providers.docker.endpoint=unix:///var/run/docker.sock"
      - "--api=true"
      - "--api.dashboard=true"
      - "--providers.docker.swarmMode=true"
      - "--providers.docker.exposedbydefault=false"
      - "--providers.docker.network=app-entry"
      - "--entrypoints.web.address=:80"
    ports:
      - 80:80
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - app-entry
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=app-entry"
      - "traefik.http.routers.traefik.rule=Host(`my-host.example.com`)"
      - "traefik.http.routers.traefik.entrypoints=web"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.middlewares=auth"
      - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
      - "traefik.http.services.traefik.loadbalancer.server.port=1337"
    deploy:
      placement:
        constraints:
          - node.role == manager

networks:
  app-entry:
    name: app-entry
    external: true

And now I get 404 using curl -vvv my-host.example.com

In access logs I see my dashboard requests and some strange things:

level=debug msg="Filtering disabled container" providerName=docker container=traefik-reverse-proxy-s06oi6rica8mbrzfl73gf7ewt

What's going wrong? Thanks in advance.

Hello,

Therefore, if you use a compose file with Swarm Mode, labels should be defined in the deploy part of your service.

https://docs.traefik.io/v2.0/providers/docker/#routing-configuration-with-labels_1

Thanks! It's working now :slight_smile:

Why my config is not working??? Seems to be same....

version: "3.3"

services:
    traefik:
        image: "traefik:v2.2.1"
        command:
            - "--log.level=DEBUG"
            
            - "--entrypoints.web.address=:80"
            - "--entrypoints.websecure.address=:443"
            
            - "--providers.docker=true"
            - "--providers.docker.exposedbydefault=false"
            - "--providers.docker.network=web" # <== Operate on the docker network named web ?!?!?!?

            # - "--api.insecure=true"
            - "--api.dashboard=true"
            - "--api.debug=true" # <== Enabling additional endpoints for debugging and profiling
            #ssl
            - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
            - "--certificatesresolvers.myresolver.acme.email=oskar@site.info"
            - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
            #swarm
            - "--providers.docker.swarmmode=true"
        ports:
            - "80:80"
            - "443:443"
            - "8080:8080"
            - "1337:1337"
        
        volumes:
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
            - "/sites/letsencrypt:/letsencrypt"
        deploy:
            labels:
                # Dashboard START
                - "traefik.enable=true"
                - "traefik.http.routers.api.rule=Host(`traefik.avizi.org`)"
                - "traefik.http.routers.api.service=api@internal"
                - "traefik.http.routers.api.middlewares=auth"
                - "traefik.http.middlewares.auth.basicauth.users=oskar:$$apr1$$q34NkOoK$$pOaJQMoiTZLYWdg.tH1Ia0"
                # Dummy service for Swarm port detection. The port can be any valid integer value.
                - "traefik.http.services.dummy-svc.loadbalancer.server.port=9999"
                # Dashboard END
            placement:
                constraints:
                    - node.role == manager

        
        networks:
            - web

I am not getting 404... but " This site can’t be reached **traefik.avizi.org** refused to connect." instead... :frowning:
My network:

networks:
    web:
        driver: overlay
        attachable: true
        external: true