Traefik session stickiness based on Backend service cookie?

Hi All,

Is it possible that traefik can use the cookie generated by the backend service for session stickiness or stickiness based on value coming in the HTTP request header?. When user login with our HTTP service a session cookie containing JWT is send to the user. Can Traefik use this cookie for stickiness? The problem why I need that is from the same machine the user can open another browser to login with our backend server that is behind the Traefik load balancer in that case load balancer might send it to another backened service. I want all the request from the user machine goes to same server initially decided by load balancer in all cases.

Regards,
IK

1 Like

Same need for KeyCloak : keycloak-documentation/sticky-sessions.adoc at master · keycloak/keycloak-documentation · GitHub

The load-balancing should be based on AUTH_SESSION_ID KeyCloak cookie whose format is <session-id>.<owner-node-id>

Hi @semangard @imtiazpk82 did you figure this out? I've stumbled upon the same.

What happens when you just use the backend cookie name (sticky doc):

## Dynamic configuration
http:
  services:
    my-service:
      loadBalancer:
        sticky:
          cookie:
            name: my_sticky_cookie_name
            secure: true
            httpOnly: true

Hi, right now I'm using this option as you described, but in this case there is plus one more cookie from traefik for stickiness. Keycloak recommendations refer to use its cookie for that.

What happens when you change the Traefik cookie name to the one from keycloak?

Hi, sorry for the delay. Nothing special - traefik puts the cookie with the same name instead of relying on the origin.