Reorder sticky session definitions

This commit is contained in:
Owen Marshall 2016-08-10 12:19:02 -04:00 committed by Emile Vauge
parent 81fddb4ccf
commit 3d7c44735a
No known key found for this signature in database
GPG key ID: D808B4C167352E59

View file

@ -546,20 +546,21 @@ func (server *Server) loadConfig(configurations configs, globalConfiguration Glo
}
stickysession := configuration.Backends[frontend.Backend].LoadBalancer.Sticky
if stickysession {
sticky := roundrobin.NewStickySession(cookiename)
cookiename := "_TRAEFIK_SERVERNAME"
var cookiename string
var sticky *roundrobin.StickySession
if stickysession {
sticky = roundrobin.NewStickySession(cookiename)
cookiename = "_TRAEFIK_SERVERNAME"
}
switch lbMethod {
case types.Drr:
log.Debugf("Creating load-balancer drr")
rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger))
if stickysession {
log.Debugf("... setting to sticky session with cookie named %v", cookiename)
rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger), roundrobin.RebalancerStickySession(sticky))
} else {
rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger))
rebalancer, _ = roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger), roundrobin.RebalancerStickySession(sticky))
}
lb = rebalancer
for serverName, server := range configuration.Backends[frontend.Backend].Servers {