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 docker-compose.yml
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?)
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 rm /path/on/host/to/traefik/dynamic-config/dashboard.yml