Quick Start Docker Compose with Dashboard enabled

Hello everyone,

I am trying to get a very basic configuration up and running with (initially insecure) Dashboard enabled. To do so, I followed (successfully) the Quick Start tutorial and added the labels required by Dashboard. Unfortunately, I am receiving 404 page not found. I found a few very similar issues on GitHub and here in the community forums, but none of them really solves my problem.

I would be grateful, if you could correct my docker-compose.yaml.

version: '3'

services:
 reverse-proxy:
   # The official v2.0 Traefik docker image
   image: traefik:v2.0
   # Enables the web UI and tells Traefik to listen to docker
   command:
     - "--api.insecure=true"
     - "--api.dashboard=true"
     - "--providers.docker"
     - "--log.level=DEBUG"
   labels:
     - "traefik.enable=true"
     - "traefik.http.routers.api.entryPoints=traefik"
     - "traefik.http.routers.api.rule=PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
     - "traefik.http.routers.api.service=api@internal"
     - "traefik.http.routers.api.middlewares=api-auth"
     - "traefik.http.middlewares.api-auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/" # test:test
   ports:
     # The HTTP port
     - "80:80"
     # The Web UI (enabled by --api.insecure=true)
     - "8080:8080"
   volumes:
     # So that Traefik can listen to the Docker events
     - /var/run/docker.sock:/var/run/docker.sock
 whoami:
   # A container that exposes an API to show its IP address
   image: containous/whoami
   labels:
     - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"

The API works fine:

$ curl  http://127.0.0.1:8080/api/rawdata
{"routers":{"api@docker":{"entryPoints":[ ...

The Dashboard doesn't:

$ curl -u test:test  http://127.0.0.1:8080/dashboard
404 page not found
1 Like

I am having a similar problem.
If i try to access localhost/dashboard I get a "404 page not found".

 curl -u testuser:testpass localhost/dashboard
404 page not found

If I try to curl localhost/api/rawdata it works.

curl -u testuser:testpass localhost/api/rawdata
{"routers":{"api@docker":{"middlewares":["basic-auth@docker"],"service":"api@internal","rule":"PathPrefix(`/api`) || PathPrefix(`/dashboard`)","status":"enabled","using":["http"]},"kafka-kafka@docker":{"service":"kafka-kafka","rule":"Host(`kafka-kafka.docker.localhost`)","status":"enabled","using":["http"]},"zookeeper-kafka@docker":{"service":"zookeeper-kafka","rule":"Host(`zookeeper-kafka.docker.localhost`)","status":"enabled","using":["http"]}},"middlewares":{"basic-auth@docker":{"basicAuth":{"usersFile":"pass"},"status":"enabled","usedBy":["api@docker"]}},"services":{"kafka-kafka@docker":{"loadBalancer":{"servers":[{"url":"http://172.18.0.2:9092"}],"passHostHeader":true},"status":"enabled","usedBy":["kafka-kafka@docker"],"serverStatus":{"http://172.18.0.2:9092":"UP"}},"traefik-traefik@docker":{"loadBalancer":{"servers":[{"url":"http://172.18.0.3:80"}],"passHostHeader":true},"status":"enabled"},"zookeeper-kafka@docker":{"loadBalancer":{"servers":[{"url":"http://172.18.0.7:22"}],"passHostHeader":true},"status":"enabled","usedBy":["zookeeper-kafka@docker"],"serverStatus":{"http://172.18.0.7:22":"UP"}}}}

My docker-compose.yml looks like this:

version: "3.3"

services:

  traefik:
    image: traefik:v2.0
    ports: 
      - "80:80"
    expose: 
      - "8080"
    volumes: 
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./pass:/pass
    labels:
      - "traefik.http.routers.api.rule=PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
      - "traefik.http.routers.api.service=api@internal" 
      - "traefik.http.middlewares.basic-auth.basicauth.usersfile=pass"
      - "traefik.http.routers.api.middlewares=basic-auth@docker"

networks:
  default:
    external:
      name: opentele3net

My traefik.yml is:

## traefik.yml

# Docker configuration backend
providers:
  docker:
    defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"

# API and dashboard configuration
api: {}

Hello,

Take a look to this blog post https://blog.containo.us/traefik-2-0-docker-101-fc2893944b9d

Hi @ldez !
Thank you for your reply.
The blog post is pretty nice and is helpful when you want to use a host rule for your dashboard.

However, I need to put the dashboard behind a subpath, so I would like to use something like PathPrefix for the dashboard. Is it possible to do so?