我正在研究HAProxy作为F5的替代品。 F5能够根据响应头值持久化会话:
when HTTP_RESPONSE { set session [HTTP::header X-Session] if {$session ne ""} { persist add uie $session } }
然后将包含相同会话ID的所有后续请求路由到同一台机器,例如:
when HTTP_REQUEST { set session [findstr [HTTP::path] "/session/" 9 /] if {$session} { persist uie $session } }
我想知道这是甚至可以做HAProxy?
HAProxy 1.5(当前的开发版本)通过stick store-response命令实现了对响应的粘性。 该命令将是这样的:
stick store-response hdr(X-Session) stick on url-param(session) # the session ID is in a query parameter # if the session ID is in the path, like /session/{session ID}/doSomething # in this case, the X-Session header value probably has to be the format "/session/{session ID}" # and the session ID length has to be fixed stick on path {session ID + path prefix length, including slashes} if path_beg "/session"
免责声明:以上是基于阅读文档,没有在实际的HAProxy安装testing。