28-Aug-2020 00:15
Hello!
I have seen around and tried to find something similar but havent found much.
The requirement is as follows and needed some help with it.
below is what i have tried so far, but do not know how to create a hash for the server IP and port and add it to irule while inserting cookie. I know something significatnt is missing, any pointers will be helpful.
#https://clouddocs.f5.com/api/irules/LB__select.html
#https://devcentral.f5.com/s/question/0D51T00006i7YuC/getting-cookie-value-and-using-switch
#https://clouddocs.f5.com/api/irules/HTTP__cookie.html
when HTTP_REQUEST {
#log cookies of client in request
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]"
foreach cookie [HTTP::cookie names] {
log local0. "[IP::client_addr]:[TCP::client_port]: Cookie $cookie = [HTTP::cookie value $cookie]"
if {not ([HTTP::cookie exists "TCS"] or[HTTP::cookie exists "DY"]) }
pool pool1
set bool 1
log local0."Pool assigned bool :$bool"
}
elseif{
if{([HTTP::cookie exists "TC"])}
{
pool pool2
}
else{
if{([HTTP::cookie exists "DY"])}
{
pool pool3
}
}
}
when HTTP_RESPONSE {
if {bool ==1 and ([LB::server addr]==10.45. or 10.45.)}
{
#Cookie insert method BigIP needs to actively insert cookie
{HTTP::cookie insert name "TC" value "TC"}
}
else {
#Passive cookie by BigIP as server will set to cookie for DY
{HTTP::cookie insert name "DY" value "DY"}
}
}