Traefik cluster serving nginx application with sticky sessions

Hi all,

I have a Traefik deployment in a docker swarm cluster with 3 masters. There is a Traefik instance running on each master. I have a ReactJS app being served with nginx.

So the flow would be like

[Internet] -> [Traefik LB] -> [Nginx serving ReactJS]

But there is a problem, when trying to access the app, sometimes if I hit one of the backends(there are 3 nginx backends) the apps loads properly, but if traefik tries to redirect the request to one of the other two backends I get 502.

I did configure sticky sessions to check if it solves the problem, but not really.

Just for the sake of testing, I scaled down the app to only one instance, and it did work properly. The problem is with the scaled app. Also I'm hitting one traefik instance, instead of hitting different traefik nodes, so to simplify the debugging.

My service has to following labels

        - "traefik.enable=true"
        - ""
        - "traefik.http.routers.frontend.rule=Host(``)"
        - "traefik.http.routers.frontend.entrypoints=https"
        - ""
        - ""
        - ""
        - "traefik.http.routers.frontend.tls=true"

I would appreciate if someone can point me in the right direction to debug and solve this issue.


I can find the following Golang error in the logs

reverseproxy.go:667: httputil: ReverseProxy read error during body copy: read tcp> read: connection timed out

502 is „Bad Gateway“, this usually happens when Traefik and your service are not on the same Docker Oberlay network or if your service uses multiple and is not set correctly.

solved ... it was an issue of the docker network and the mtu