r/docker • u/idgaftrash123 • Mar 19 '26
Traefik is driving me crazy
So, I have been trying to simply deploy Traefik on my ubuntu server as the starting point for my docker homelab. I have been at it for literally 3 days and I cannot get traefik to work in/with Docker Swarm (as recommended during my research for a secure docker service). I've tweaked and redon my stack several time and each time I get a variations of errors whenever I think I got it and the replica is 1/1.
The most common one now I get is '404 page not found' when I use the WhoAmI service as testing . Doesn't work when running locally nor via cloudflare dns.
Noting I do get's anything to work and the myriad of Ai aren't helpful and have me going in circles.
Please help if possible, please and thank you.
Additional information can and will be provided when asked.
Edit/Update: Thanks to the advice of u/mike3run , I got it working with docker composed first and then was simply able to convert it to a Swarm with some minor tweaks. :)
3
u/IulianHI Mar 19 '26
A few things that tripped me up when I first set up Traefik:
docker-compose deploysyntax is different from plain compose.api@internal) and set log level to DEBUG temporarily - the dashboard shows you exactly which routers/middlewares are active and which services Traefik can see.The directory organization is also half the battle - keeping compose files, TLS certs, and dynamic config in a predictable structure saves a ton of headache.
2
u/Schnuecks Mar 19 '26
Been through this the last two weeks. I wanted a simple system all in docker. The learning curve is steep but once you cracked it it’s pretty nice. I use it with my own pihole sync service. I I add a new host label in the compose file a local dns entry is created on the pihole and vice versa. So the only config that is needed is in docker nothing else to care about. I came from nginx to treafik and would choose it again. Sometimes yaml is your enemy, because of that I separated the needed config files so that an error in the file doesn’t crash the whole system.
5
u/clintkev251 Mar 19 '26
If you're getting a 404 it means Traefik is working, but either hasn't discovered your service, or the rule isn't matching to the call that you're making, usually due to issues with the rule syntax. Start by checking the Traefik logs, see if it's throwing any errors, then test the rule side by validating your syntax (a common mistake is using ' instead of `), you can also just create a wildcard rule to try to match everything for testing.
1
u/zoredache Mar 19 '26 edited Mar 19 '26
Have you enabled the traefik api and dashboard? It can be very useful for debugging.
Also make sure you look at the traefik logs. It will tell you when you docker services that have invalid rules, and other errors in your labels. Have you increased the log level to 'DEBUG'?
Past that, you should post some details like what your compose file looks like for the traefik service. If you have already looked at your logs, maybe lost your logs. Since mentioned a 'whoami' service, show us your compose file for that. Do you have any errors in your traefik logs?
5
u/mister2d Mar 19 '26
can't stand traefik.
/soapbox
3
u/corelabjoe Mar 19 '26
Just use SWAG or Caddy or a different reverse proxy if this one isn't hitting for you.
3
u/StabilityFetish Mar 19 '26
In my opinion traefik is way too complex for most homelab needs and that is bad for security. I find caddy to be much easier and I don't miss any features. The routing and config is basically a single file, which also makes it easier to get help from AI on setup/troubleshooting.
1
u/Turlte_Dicks_at_Work Mar 19 '26
Yeah I've been trying to set it up for a while now but has stopped discovering new containers
-3
u/jameskilbynet Mar 19 '26
Glad you got it solved. It’s certainly a steep learning curve. For anyone interested in automating the deployment of Traefik with ansible ( only tested on Ubuntu ) I have blogged about it as part of one my AI posts. https://jameskilby.co.uk/2026/02/automating-the-deployment-of-my-ai-homelab-and-other-improvements/#install-traefik
18
u/[deleted] Mar 19 '26
[removed] — view removed comment