Hi, I'm using Traefik sticky sessions and want to be able calculate cookie value which should be hash of the server URL. Use case is to let admin user to select the desired worker instance.
According traefik/pkg/server/service/service.go at v3.1.7 · traefik/traefik · GitHub
it should be easy. But I am getting different values than the Traefik is sending to the client. For verification I am using URLs from Traefik dashboard as the input of the hashing:
Can anybody help me confirm that this is the right hashing place and correct input for Docker Swarm?
Verification: Go Playground - The Go Programming Language
Heh, I've just discovered that there is another hashing place of the server hash:
http.Error(w, errNoAvailableServer.Error(), http.StatusServiceUnavailable)
} else {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
return
}
if b.stickyCookie != nil {
cookie := &http.Cookie{
Name: b.stickyCookie.name,
Value: hash(server.name),
Path: "/",
HttpOnly: b.stickyCookie.httpOnly,
Secure: b.stickyCookie.secure,
SameSite: convertSameSite(b.stickyCookie.sameSite),
MaxAge: b.stickyCookie.maxAge,
}
http.SetCookie(w, cookie)
}
server.ServeHTTP(w, req)
Now I'm getting correct hash: Go Playground - The Go Programming Language
system
Closed
November 9, 2024, 11:45pm
3
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.