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
This commit is contained in:
Yousong Zhou
2020-02-18 20:55:10 +08:00
parent a2f30806cf
commit 2e0f424c73
+6 -2
View File
@@ -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 != "" {