From 2e0f424c731397e887ede282293c6566d1721f9e Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Tue, 18 Feb 2020 20:53:10 +0800 Subject: [PATCH] lbagent: fix config for sticky session cookie - account for user specific cookie name for insert mode - dont tamper cache instructions from backend server for server mode --- pkg/lbagent/models/haproxy.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/lbagent/models/haproxy.go b/pkg/lbagent/models/haproxy.go index 1227eaf8d2..492ddac11c 100644 --- a/pkg/lbagent/models/haproxy.go +++ b/pkg/lbagent/models/haproxy.go @@ -285,14 +285,18 @@ func (b *LoadbalancerCorpus) genHaproxyConfigBackend(data map[string]interface{} stickyCookie := "" switch listener.StickySessionType { case "insert": - stickyCookie = "cookie SERVERID insert indirect nocache" + cookie := listener.StickySessionCookie + if cookie == "" { + cookie = "SERVERID" + } + stickyCookie = fmt.Sprintf("cookie %s insert indirect nocache", cookie) if maxIdle := listener.StickySessionCookieTimeout; maxIdle > 0 { stickyCookie += fmt.Sprintf(" maxidle %ds", maxIdle) } case "server": cookie := listener.StickySessionCookie if cookie != "" { - stickyCookie = fmt.Sprintf("cookie %q rewrite nocache", cookie) + stickyCookie = fmt.Sprintf("cookie %q rewrite", cookie) } } if stickyCookie != "" {