Can dashboard be configured in dynamic config file?

I successfully configured the api/dashboard in docker-compose.yml.

However, due to my other issue I want to move that config to a separate dynamic config file.

This is what I did:

docker-compose.yml:

services:
  traefik:
    # ...
    volumes:
      - ./config/:/etc/traefik/config/:ro
    command:
      - --providers.file.directory=/etc/traefik/config/
      - --providers.file.watch=true
      - --api=true
    # ...

./config/api.yml:

http:
  routers:
    dashboard:
      entrypoints:
        - websecure
      rule: Host(`dashboard.example.com`) && PathPrefix(`/api`, `/dashboard`, `/debug`)
      middlewares:
        - auth
      service: api@internal
  middlewares:
    auth:
      basicAuth:
        usersfile: /run/secrets/api

./config/tls.yml:

# this dynamic config files works!

./config/other.yml:

# this dynamic config files works!

Traefik starts without errors in the logs. But when I visit https://dashboard.example.com/dashboard/ I get a 404.

All examples I've seen configure the dashboard in docker-compose.yml. Is it actually possible to do it in a separate dynamic config file?

If yes, the issue is probably config - can you spot my error?

Thanks.

Yes, dashboard routing can be done in a separate dynamic config file. (Doc)

I think you forgot to enable dashboard in static config.

1 Like

I wasn't even sure what I was trying was possible, so thanks for the confirmation!

No I did enable it with --api=true above.

So my problem must be elsewhere. Must dig some more...

That was very difficult to diagnose.

I had this in docker-compose.yml:

- --entrypoints.websecure.http.middlewares=headers@file,compress

The compress middlware was defined in the same docker-compose.yml file, so I didn't realise I need to append @docker (I thought @docker and @file was only needed when the middleware was defined in a separate file).

When I fixed it:

- --entrypoints.websecure.http.middlewares=headers@file,compress@docker

The dashboard started working.

Thanks for your help.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.