traefik: Backend stickiness not working

Do you want to request a feature or report a bug?

Bug

What did you do?

Using traefik 1.7.0 rc3, and the load balancer stickiness setting, it is not applying the stickiness when proxying two IIS web servers that are using Windows Authentication. The windows authentication piece sends two 401 requests to the backend server to establish the “session” but traefik is sending the two requests to the two different backend servers. I have verified in the logs that it says "Sticky session with cookie " and so I think the configuration is being read correctly by traefik. Could traefik not be inserting the cookie on 401 requests?

What did you expect to see?

Expected to see the multiple requests from the same client directed to the same backend server

What did you see instead?

Multiple requests from the same client went to different backend servers

Output of traefik version: (What version of Traefik are you using?)

Version:      v1.7.0-rc3
Codename:     maroilles
Go version:   go1.10.3
Built:        2018-08-01_01:37:51PM
OS/Arch:      linux/amd64

What is your environment & configuration (arguments, toml, provider, platform, …)?

  [backends.XXX]
    [backends.XXX.loadbalancer]
      method = "wrr"
    [backends.XXX.loadbalancer.stickiness]
      cookieName = "__trae_proxy"
    [backends.XXX.healthcheck]
      path = "/"
      interval = "5s"
    [backends.XXX.servers.test01]
      url = "http://test01:80"
    [backends.XXX.servers.test0]
      url = "http://test02:80"

If applicable, please paste the log output at DEBUG level (--logLevel=DEBUG switch)

time="2018-08-16T13:04:49-05:00" level=debug msg="Creating backend test"
time="2018-08-16T13:04:49-05:00" level=debug msg="Creating load-balancer drr"
time="2018-08-16T13:04:49-05:00" level=debug msg="Sticky session with cookie __trae_proxy"
time="2018-08-16T13:04:49-05:00" level=debug msg="Creating server test02 at http://test02:80 with weight 0"
time="2018-08-16T13:04:49-05:00" level=debug msg="Creating server test01 at http://test01:80 with weight 0"

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

I have the same problem. Backend stickyness as described in the documentation does not work with 1.7, while it works with 1.6 with the same configuration.

linked to #3975

If it helps to track down the issue, I’ve just tried to deploy our app in JBoss EAP 7 and I can confirm the behaviour reported by @seeruk .

Using the new stickiness property traefik.backend.loadbalancer.stickiness=true does NOT work. Switching to traefik.backend.loadbalancer.sticky=true makes Traefik show the cookie name in the log and session stickiness works as expected.

This issue though doesn’t seem to affect the Swarm mode example shown in the official Swarm example. I tried it and it works as expected (using curl at least).

Adding more info to the thread, the issue persists on v1.7.4

Version:      v1.7.4
Codename:     maroilles
Go version:   go1.11.1
Built:        2018-10-30_10

Config toml

debug = false

logLevel = "ERROR"
defaultEntryPoints = ["https","http"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]

[retry]

[docker]
endpoint = "tcp://127.0.0.1:2376"
domain = "my.domain"
watch = true
exposedByDefault = false
swarmMode = true

[acme]
email = "email@test.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"

compose file

version: '3'
services:
  whoami:
    image: jwilder/whoami
    networks:
      traefik-net:
        aliases:
        - whoami-${SUBDOMAIN}
    deploy:
      labels:
      - "traefik.docker.network=traefik-net"
      - "traefik.frontend.rule=Host:whoami.${SUBDOMAIN}.${DOMAIN}"
      - "traefik.backend=whoami-${SUBDOMAIN}"
#      - "traefik.backend.loadbalancer.swarm=true"
      - "traefik.backend.loadbalancer.stickiness=true"
#      - "traefik.backend.loadbalancer.stickiness.cookieName=lb_test"
      - "traefik.port=8000"
      - "traefik.protocol=http"
      - "traefik.enable=true"
networks:
  traefik-net:
    external: true

(It does not work regardless those commented lines are uncommented or not)

Observation

I deployed the compose file, with 1 whoami container, I can see the cookie in my browser.

Clean the cookie, docker service scale to 2, no cookie.

Confirmed that this is a regression. Sticky sessions work as expected in 1.6.5.