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.docker.network=traefik-net"
        - "traefik.http.routers.frontend.rule=Host(`app.example.com`)"
        - "traefik.http.routers.frontend.entrypoints=https"
        - "traefik.http.services.frontend.loadbalancer.server.port=8080"
        - "traefik.http.services.frontend.loadbalancer.sticky=true"
        - "traefik.http.services.frontend.loadbalancer.sticky.cookie.name=StickyCookie"
        - "traefik.http.routers.frontend.tls=true"

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

thanks.

I can find the following Golang error in the logs

reverseproxy.go:667: httputil: ReverseProxy read error during body copy: read tcp 10.0.1.177:38364->10.0.1.189:8080: 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 docker.network is not set correctly.

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