Forum Discussion

stanjavoor's avatar
stanjavoor
Icon for Nimbostratus rankNimbostratus
May 15, 2020

Assistance with Session Persistence iRule

when HTTP_REQUEST {
 
if {([string tolower[HTTP::uri] matches_regex {\/wps\/myportal\((?!\?).)*$}] and ([string tolower [HTTP::cookie exists portal2_cookie]]))} {
pool login_debug_pool
persist cookie rewrite l_cookie 0
}
elseif { ([string tolower [HTTP::uri]] contains "/abc" or [string tolower [HTTP::uri]] contains "/abcr" or [string tolower [HTTP::cookie exists b_cookie]] ) } {
pool app_debug_pool
persist cookie insert b_cookie 0
}
elseif { ([string tolower [HTTP::uri]] contains "/pqr" or [string tolower [HTTP::uri]] contains "/aps" or [string tolower [HTTP::cookie exists p_cookie]]) } {
pool pqr_debug_pool
persist cookie insert p_cookie 0
}
elseif { ([matchclass [HTTP::uri] contains PORTAL2_URI] or [string tolower [HTTP::cookie exists portal2_cookie]]) } {
pool portal2_debug_pool
persist cookie insert portal2_cookie 0
}
elseif { ([matchclass [HTTP::uri] contains PORTAL1_URI] or [string tolower [HTTP::cookie exists o_cookie]]) } {
pool others_debug_pool
persist cookie insert o_cookie 0 
}
else {
pool login_debug_pool
persist cookie insert l_cookie
}
 
if { [HTTP::uri] contains "/oam_logout_success" } {
HTTP::respond 302 Location "https://[HTTP::host]/wps/portal" "Cache-Control" "no-cache, must-revalidate" "Set-Cookie" "l_cookie=;path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT" "Set-Cookie" "b_cookie=;path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT" "Set-Cookie" "p_cookie=;path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT" "Set-Cookie" "o_cookie=;path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT" "Set-Cookie" "l_cookie=;path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT" "Set-Cookie" "portal2_cookie=;path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT" 
}
 
}
 
when HTTP_RESPONSE {
 
if { not([HTTP::header exists "X-Frame-Options"])}{
    HTTP::header insert X-Frame-Options "SAMEORIGIN"
  } else {
    HTTP::header replace X-Frame-Options "SAMEORIGIN"
  }
if { not([HTTP::header exists "X-FRAME-OPTIONS"])}{
    HTTP::header insert X-FRAME-OPTIONS "SAMEORIGIN"
  } else {
    HTTP::header remove X-FRAME-OPTIONS
    HTTP::header insert X-FRAME-OPTIONS "SAMEORIGIN"
  }
 
if {![HTTP::cookie exists "DC"]} {
	HTTP::cookie insert name "DC" value "NY" path "/" version 1
	HTTP::cookie secure DC enable
	HTTP::cookie httponly DC enable
    }
 
foreach x [HTTP::cookie names] {
    if { $x starts_with "BIGipServer" } {
        HTTP::cookie remove $x
        HTTP::cookie insert name $x value [HTTP::cookie $x] path "/" version 1
        HTTP::cookie secure $x enable
        HTTP::cookie httponly $x enable
        }
    }
}

Trying to do session persistence based on uri between multiple pools and need assistance with iRule, it is partially working and need some insights how to get it working.

if {([string tolower[HTTP::uri] matches_regex {\/wps\/myportal\((?!\?).)*$}] and ([string tolower [HTTP::cookie exists portal2_cookie]]))} {
pool login_debug_pool
persist cookie rewrite l_cookie 0
}

Above logic is being intercepted in F5 but all the requests not loading completely. If I delete the cookie portal2_cookie from browser tab manually, then it works properly.

I'm trying to figure out a way on how to delete the cookie in the response or if there is any way to get all the subsequent uri's loaded when switching pools with persistence.

Thanks,

Susheel

No RepliesBe the first to reply