The dashboard is very useful, but:
- once my server is running properly, I want to disable it
- if I run into problems, I want to enable it for debugging / troubleshooting purposes
However it is configured in the static config, so I must restart traefik (which impacts dependent services).
I wanted a quick way to do this, maybe in a script. What I tried:
- I put all my static config in
- I created a
traefik.yml file and put only the
api config in there, nothing else
- I created a
toggle-dashboard.sh bash script that edits
traefik.yml by toggling
dashboard: true between true/false, and then runs
docker compose restart traefik
- This minimises bugs by editing a simple static file, instead of a large complex compose file
What I discovered is that traefik doesn't work properly when some static config is in
docker-compose.yml and some in
traefik.yml. So this approach failed.
What other options are there, if any? What do other people do? (Maybe others just leave the dashboard, with basic auth, running all the time?)
Update: I added a feature request to the repo (for toggling the api/dashboard at runtime via dynamic config).
You should be able to add and remove the dashboard router in a dynamic config file, loaded via
Thanks bluepuma, I didn't think of that.
This is my dynamic config file:
rule: Host(`dashboard.example.com`) && PathPrefix(`/api`, `/dashboard`, `/debug`)
So if I understand you correctly, at runtime, I can simply delete those lines. Then traefik will delete the associated router, which means that even though the api/dashboard is enabled in the static config (
--api=true), any requests to
https://dashboard.example.com/dashboard/ will not have a matching router, so it will respond with 404.
If that is correct, then there maybe is an even more elegant solution, which is to have multiple dynamic config files (file watcher in a directory). Then instead of editing the file (potential for errors), script can run:
- to enable
cp dashboard.yml /path/on/host/to/traefik/dynamic-config/dashboard.yml
- to disable
What do you think... good/bad idea?
Yes, that should work, just enable
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.