Is there any option to keep last known routing configuration instead of disabling routing when configuring by mistake a routing middleware that does not exist?
Traefik doesn't have a built-in "last known good configuration" fallback for this scenario. When a router references a middleware that doesn't exist, Traefik marks that router as having a configuration error and stops routing traffic for it entirely — there's no fallback to the previous working state.
The closest thing to resilient behavior depends on your provider:
If you're using the file provider with watch mode, a syntax error or reference to a missing middleware causes Traefik to reject the new config file entirely and keep the previous one. So the "last known good" behavior you want is effectively automatic there — the error has to be in the file itself, not a middleware that exists in a separate file that gets deleted.
For Docker or Kubernetes providers, there's no equivalent safety net — Traefik continuously reconciles with the current state of labels/annotations/CRDs, so removing a middleware definition will immediately break any routers that reference it.
The practical workaround is to treat middleware definitions as dependencies that must exist before any router references them. In Kubernetes this means managing the IngressRoutMiddleware (or equivalent) lifecycle carefully before updating the IngressRoute. In Docker, define your middlewares in a separate file provider config rather than as labels, which gives you the file-provider safety net.
There's a similar thread on the forum discussing invalid middleware handling that might have additional context: Resilient routing on invalid middlewares