Forum Discussion
iRule Universal Persistence
Hi,
I am hoping someone can help with this issue, or at least point me in the right direction.
I have 2 VS using the same VIP running on port 80 and 443.
I have no default pool selected on these VS, as I am using iRules to do this as shown below:
when HTTP_REQUEST {
Check the URI, set to lowercase
switch -glob [string tolower [HTTP::uri]] {
"/Folder1/*" -
"/Folder2/*" -
"/Folder3/*" {pool HTTP-ThirdParty}
default {pool HTTP-MainSite}
}
}
and
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/Folder1/*" -
"/Folder2/*" -
"/Folder3/*" pool HTTPS-ThirdParty}
default { pool HTTPS-MainSite }
}
}
This works fine.
I am then using Universal Match Across Services persistence profile from this example:
https://devcentral.f5.com/wiki/iRul...tence.ashx
So the match across services for HTTP and HTTPS works fine because the pool has the same member ip's. But anything that goes to the pool HTTPS-ThirdParty and HTTP-ThirdParty doesn't set its own persistence.
We require persistence across our third party apps as well, so I attempted to modify the iRule to add persistence using a differently named cookie for the other pool like this:
when HTTP_REQUEST {
if { ([LB::server pool] eq "/Common/HTTP-MainSite") } {
if { [HTTP::cookie value "cookieMainWebsite"] ne "" } {
persist uie [HTTP::cookie value "cookieMainWebsite"]
set need_cookie 0
} else {
set need_cookie 1
}
}
if { ([LB::server pool] eq "/Common/HTTP-ThirdParty") } {
if { [HTTP::cookie value "cookieThirdParty"] ne "" } {
persist uie [HTTP::cookie value "cookieThirdParty"]
set need_cookie 0
} else {
set need_cookie 1
}
}
}
when PERSIST_DOWN {
set need_cookie 1
}
when HTTP_RESPONSE {
if { $need_cookie } {
if { ([LB::server pool] eq "/Common/HTTP-MainSite") } {
HTTP::cookie insert name "cookieMainWebsite" value [IP::server_addr] path "/"
persist add uie [HTTP::cookie value "cookieMainWebsite"]
}
if { ([LB::server pool] eq "/Common/HTTP-ThirdParty") } {
HTTP::cookie insert name "cookieThirdParty" value [IP::server_addr] path "/"
persist add uie [HTTP::cookie value "cookieThirdParty"]
}
}
}
I suspect my expression when I attempt to check the current pool isn't quite right. Hopefully you can understand what I am trying to achieve, but please ask for clarification on any bits that are unclear.
- nitassEmployeein HTTP To HTTPS Cookie Persistence irule, can you try to append "priority 600" to HTTP_REQUEST event?
- nitassEmployeewhen HTTP_REQUEST {
- Hi Nitass,
- Sorry Nitass,
- Hi Nitass,
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com