# Name : Virtual Server Cookie Persistence (standard) # Purpose : Cookie Persistence across Virtual Server services # Methodology : Create cookie containing "unique" hash. This cookie is then used to persist connections. when HTTP_REQUEST { if { [HTTP::cookie exists "b1P"] } { # if cookie is present then persist persist uie [HTTP::cookie value "b1P"] set cookie_check 0 #_debug_# log local0. "[virtual name] [IP::client_addr] PRESENT [HTTP::cookie value "b1P"] 0" } else { set cookie_check 1 } } when HTTP_RESPONSE { # if there is no cookie in request then add cookie to response if { $cookie_check eq 1 } { # create hash for cookie set now [clock seconds] set token "[IP::server_addr][IP::client_addr][TCP::client_port][expr { int(1000000 * rand()) }]" binary scan [md5 $token] H* md5var junk # insert cookie HTTP::cookie insert name "b1P" path / value $md5var\_$now #_debug_# log local0. "[virtual name] [IP::client_addr] INSERT [HTTP::cookie "b1P"] 1" persist add uie [HTTP::cookie "b1P"] } }