Skip to content

Instantly share code, notes, and snippets.

@paneq
Last active December 27, 2024 21:28
Show Gist options
  • Save paneq/0a3e0bf3a69314f3b283f1c703288d88 to your computer and use it in GitHub Desktop.
Save paneq/0a3e0bf3a69314f3b283f1c703288d88 to your computer and use it in GitHub Desktop.
Traefik 404 errors solution.

I configured Traefik via /etc/traefik/traefik.toml in docker-compose.yml, but all routes were giving me 404 Not Found results. The routing did not even work, nothing was forwarded to the right service.

The culprit turned out to be that providers need to be configured.

services:
traefik:
image: "traefik:v3.2"
container_name: "traefik"
command:
- "--configFile=/etc/traefik/traefik.toml"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik.toml:/etc/traefik/traefik.toml"
curl -i 'http://localhost:80/foo'
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Fri, 27 Dec 2024 18:38:51 GMT
Content-Length: 19
404 page not found
[providers]
[providers.file]
filename = "/etc/traefik/traefik.toml"
[log]
level = "DEBUG"
[accessLog]
[api]
insecure = true
dashboard = true
[entryPoints]
[entryPoints.web]
address = ":80"
[http]
[http.routers]
[http.routers.todo]
rule = "PathPrefix(`/`)"
service = "todo"
entryPoints = ["web"]
[http.services.todo.loadBalancer]
[[http.services.todo.loadBalancer.servers]]
url = "http://host.docker.internal:4000"
[providers] # 404 not found - solution
[providers.file]
filename = "/etc/traefik/traefik.toml"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment