I have 2 DCs fronted by a software GTM solution. When a user makes a request, GTM checks to see if they have a “DC” cookie. If they don’t, it round robins the request. In the event that DC1 gets the request, the F5 there sets a cookie named “DC” with the value “1” and a server cookie for server-persistency. That way, GTM looks at the cookie and gets DC persistency. If a DC goes bad, GTM will send the request to the other DC even though the cookie exists. So, the F5 at DC2 may see a cookie named “DC” with the value of “1”. If that happens, I want the F5 at DC2 to remove the cookie. Am I on the right track here?
when HTTP_REQUEST {
set strDC [HTTP::cookie "DC"]
if { $strDC equals "1"} {
HTTP::cookie remove "DC"
HTTP::cookie remove "server"
}
}
If you want the client to delete a cookie you’d need to tell it to in the response. Using HTTP::cookie remove in HTTP_REQUEST is going to remove the cookie from the request that is proxied to the pool--it wouldn’t have any effect on the client.
Can you try this?
when HTTP_REQUEST {
if {[HTTP::cookie "DC"] eq "1"}{
set remove_cookies 1
} else {
set remove_cookies 0
}
}
when HTTP_RESPONSE {
if {$remove_cookies}{
HTTP::cookie remove "DC"
HTTP::cookie remove "server"
}
}
If I am following your logic you want to remove the cookie from the client context?
If so then you would need to use the HTTP_RESPONSE event.
Here is the untested iRule
when HTTP_REQUEST {
set the value for location in the cookie
set StrDC [HTTP::cookie "DC"]
}
when HTTP_RESPONSE {
checks to see if there is a 1 or a cookie header with no value
if { ($StrDC== "1") or {$StrDC=="" } {
HTTP::cookie remove "DC"
HTTP::cookie remove "server"
}
}
You can insert a new session and that will overwrite the current one.
when HTTP_REQUEST {
set logOut 0
if {(([HTTP::uri] ends_with "logout")}
{
set logOut 1
}
}
when HTTP_RESPONSE {
if { $logOut == 1 }
{
set session_key "whatever0928340923any"
HTTP::cookie insert name "DC" value $session_key
HTTP::cookie insert name "server" value $session_key
}