This episode covers the file provider: writing routers, services, and middlewares in YAML or TOML files with directory watching and hot reload, the http, tcp, udp, and tls section structure, configuration validation, and best practices for non-container services.

So far, dynamic configuration has come from Docker labels. But what about services that do not live in Docker — bare-metal servers, VMs, or applications with static backends? Episode 19 answers with the file provider: writing routers, services, and middlewares in YAML/TOML files that Traefik reads directly.
Its biggest advantage is the same as other providers: hot reload. Traefik watches the files and applies changes without a restart. Combined with an explicit structure that is easy to version-control, the file provider is the primary choice for complex and hybrid configurations.
The file provider is defined in static config, pointing to a directory or a single file:
providers:
file:
directory: /etc/traefik/dynamic
watch: truedirectory: the folder containing dynamic configuration files.watch: true: Traefik monitors changes and reloads automatically.Every .yml, .yaml, or .toml file in that directory is read as one dynamic configuration block. Multiple files are allowed; Traefik merges them all. The file name is used as the log label — give descriptive names like routers.yml, middlewares.yml, certificates.yml.
The top-level structure of a dynamic file mirrors the protocol split:
http: routers, services, middlewares for HTTP.tcp: routers and services for TCP.udp: routers and services for UDP.tls: certificates and options.A complete example for two services:
http:
routers:
blog:
rule: "Host(`blog.example.com`)"
entrypoints:
- web
- websecure
service: blog-svc
middlewares:
- secure-headers
api:
rule: "Host(`api.example.com`) && PathPrefix(`/v2`)"
entrypoints:
- websecure
service: api-svc
tls: {}
services:
blog-svc:
loadBalancer:
servers:
- url: "http://192.168.1.20:8080"
healthCheck:
path: "/health"
interval: "20s"
api-svc:
loadBalancer:
servers:
- url: "http://192.168.1.21:3000"
- url: "http://192.168.1.22:3000"
middlewares:
secure-headers:
headers:
frameDeny: true
contentTypeNosniff: trueNote that the servers are static IPs without Docker — this is the power of the file provider for hybrid infrastructure.
When a file changes, Traefik immediately validates and applies the new configuration. If a file contains syntax errors or broken references, Traefik rejects that update and keeps the previous valid configuration — no downtime because of a typo.
Verify that changes were accepted through the logs or the API:
docker logs traefik
curl -s http://localhost:8080/api/http/routersA log message like Configuration loaded from file indicates a successful reload. The /api/http/routers API endpoint shows the currently active routers. The curl command is a quick way to confirm file changes are really applied before moving on.
Errors that often appear when working with many files:
traefik checkConfig before applying to production.Tip
The file provider and the Docker provider can coexist. Use Docker for container workloads and the file provider for external services — Traefik merges both into a single routing graph.
Key takeaways:
watch: true.http, tcp, udp, and tls sections.In episode 20 next we enter the Kubernetes phase: kubernetes provider ingress — IngressClass and Ingress resources, host and path-based routing, the traefik.ingress.kubernetes.io/* annotations, TLS with Secrets and cert-manager, and Kubernetes Service types. Traefik works differently in the orchestrator world.