I'm using traefik for over a year and is working great, but i have trouble making it run in swarm mode.
My setup
I have a docker swarm with 1 manager and 1 worker. Both are on an overlay network called "traefik_net"
Traefik run on the manager node and my web apps on the worker.
The issue
Service discovery work perfectly fine, the only issue is that i cannot access my services if deployed on the worker node, if i deploy them on the manager node i can access them.
If i try to access my webapp it load for few seconds and my browser return a 400 error.
What i've tryed
From within the traefik container I can make a wget on a service running in the worker node therefore i assume that the swarm network is working well.
Running my apps on the manager node, work well.
Look at traefik log on DEBUG mode, there is none when i try to access my service.
In the dasboard my services have correct IP:PORT in the 'Servers' section
As it work if my services run on the manager i assume my docker compose is correct.
Thanks for the lead but unfortunatly it doesn't seems that's the source of my issue.
I tested to ping between the node with high packet size and it work, also i can access my service if t dont go thought traefik so i think that the network side is ok.
How do you know the service is on worker? You set replicas: 1, but no constraint.
You use host.docker.internal, which is only supported by Docker Desktop.
You use --api.insecure=true, make sure to remove this when put in production. It will ignore any middlewares for auth, also you assign middlewares=auth which does not seem to exist.
Note that you can assign the certresolver globally on entrypoint. Maybe check your config against simple Traefik example.
Last note: you use MY_DOMAIN for Traefik dashboard and your service, of course they must be different.
Thanks for this feed back, i was checking where my services was running with docker command but adding a constraint is a good idea !
MY_DOMAIN is obviously set accordingly on my docker compose and i can confirme that it work well because if i force my service on the manager node everything works.
So using this new compose it does work if i use node.role == manager and i get a HTTP ERROR 400 from chrome after ~1min when using node.role == worker.
So Traefik forward works when the target service runs on manager, but not on worker? YES
Is traefik_net a Docker Swarm overlay network? YES
And i can confirm that the network works because i can make a wget from the traefik container (docker exec) to the ip of the swarm network. Also this IP is the same as the one shown in the traefik dashboard (HTTP > Services => Servers) so traefik detect the correct IP and use the correct port
Have you tried with a simple whoami service instead? Not yet
When using a VPN, usually the MTU of TCP packets needs to be reduced. Make sure your Docker Swarm overlay network has a MTU that fits inside the VPN MTU.