Ok.
After digging into traefik logs, it seems that I was not using the right syntax for stickiness...
My new myapp.yml
file:
version: '3.7'
services:
myapp:
image: myapp
ports:
- ${MYAPP_PORT?Variable not set}
deploy:
mode: replicated
replicas: 12
restart_policy:
condition: on-failure
labels:
- traefik.enable=true # enable traefik
- traefik.docker.network=traefik-public # put it in the same network as traefik
- traefik.constraint-label=traefik-public # assign the same label as traefik so it can be discovered
- traefik.http.routers.idcovserv.rule=Host(`${MYAPP_FQDN?Variable not set}`) # listen to port 80 for request to APP_DOMAIN (use together with the line below)
- traefik.http.routers.idcovserv.entrypoints=http
- traefik.http.middlewares.idcovserv.redirectscheme.scheme=https # redirect traffic to https
- traefik.http.middlewares.idcovserv.redirectscheme.permanent=true # redirect traffic to https
- traefik.http.routers.idcovserv-secured.rule=Host(`${MYAPP_FQDN?Variable not set}`) # listen to port 443 for request to APP_DOMAIN (use together with the line below)
- traefik.http.routers.idcovserv-secured.entrypoints=https
- traefik.http.routers.idcovserv-secured.tls.certresolver=le # use the Let's Encrypt certificate we set up earlier
- traefik.http.services.idcovserv-secured.loadbalancer.server.port=${MYAPP_PORT?Variable not set} # Ask Traefik to loadbalancing on this port
- traefik.http.services.idcovserv-secured.loadbalancer.sticky.cookie=true
networks:
- back-net
- traefik-public
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
traefik-public:
external: true
back-net:
external: true
Hope it would help other people. And just to clarify, the loadbalancing port on traefik service has nothing to do with the app loadbalancing port.
Thanks.