Unable to configure the dashboard in Docker Swarm deployment

Hello,

I have a problem to configure the secure dashboard with Docker Swarm and without the "Host" clause. I still get a 404 error. The "whoami01" service work well.

version: '3.8'

services:
  traefik:
    image: traefik:v2.9
    command:
      # Use Docker Swarm
      - --providers.docker=true
      - --providers.docker.swarmmode=true
      - --providers.docker.exposedbydefault=false
      # Add the entrypoints
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      # Redirect 80 -> 443
      - --entrypoints.web.http.redirections.entryPoint.to=websecure
      - --entrypoints.web.http.redirections.entryPoint.scheme=https
      - --entrypoints.web.http.redirections.entrypoint.permanent=true
      # Add configuration files
      - --providers.file.directory=/configuration/
      - --providers.file.watch=true
      # Enable dashboard
      - --api.dashboard=true
      # Enable logs
      - --log.level=DEBUG
      - --log.filePath=/tmp/traefik.log
      # Enable access logs
      - --accesslog=true
      - --accesslog.filepath=/tmp/access.log
      - --accesslog.bufferingsize=100
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - traefik-configuration:/configuration/
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.dashboard.rule=PathPrefix(`/api`, `/dashboard`) # https://localhost/dashboard/
        - traefik.http.routers.dashboard.entrypoints=websecure
        - traefik.http.routers.dashboard.tls=true
        - traefik.http.routers.dashboard.service=api@internal
        - traefik.http.services.dummy-svc.loadbalancer.server.port=9999

  whoami01:
    image: traefik/whoami:latest
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.whoami01.rule=Path(`/whoami01`) # https://localhost/whoami01/
        - traefik.http.routers.whoami01.entrypoints=websecure
        - traefik.http.routers.whoami01.tls=true
        - traefik.http.services.whoami01.loadbalancer.server.port=80
      
volumes:
  traefik-configuration:

Can you help me please?
Thank you.

Make sure to use /dashboard/ in your browser.

I'm sure, I tested:

  • https://[ip]:9000/dashboard
  • https://[ip]:9000/dashboard/
  • https://[ip]:9000/api
  • https://[ip]:9000/api/

But you dashboard entrypoint is websecure, so 443 :grinning:

I'm sorry, my message was wrong :slight_smile:

I'm sure, I tested:

  • https://[ip]/dashboard
  • https://[ip]/dashboard/
  • https://[ip]/api
  • https://[ip]/api/

Try adapting the rule to below format, see docs.

# Dynamic Configuration
labels:
  - "traefik.http.routers.dashboard.rule=PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
  - "traefik.http.routers.dashboard.service=api@internal"
  - "traefik.http.routers.dashboard.middlewares=auth"
  - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"

Unfortunately I still get the 404 error :frowning:

Assuming you have static certificates via dynamic TLS configuration.

# Dynamic Configuration
labels:
  - "traefik.enable=true"
  - "traefik.http.routers.dashboard.entrypoints=websecure"
  - "traefik.http.routers.dashboard.tls=true"
  - "traefik.http.routers.dashboard.rule=PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
  - "traefik.http.routers.dashboard.service=api@internal"
  - "traefik.http.routers.dashboard.middlewares=auth"
  - "traefik.http.middlewares.auth.basicauth.users=test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"

[/quote]

Then use https://hostname/dashboard/