Forum Discussion
Select Pool Based on URI Persistence
We have a QA platform qa-example.com that we want to use to test three different versions of code: 1.0, 1.1, and 1.2.
The default pool points to 1.0, qa-example.com-g1_pool points to 1.1, and qa-example.com-g2_pool points to 1.2
The developers want to point to qa-example.com/g1/[additional query parameters] to test 1.1 and point to qa-example.com/g2/[additional query parameters] to test 1.2
The application does not recognize /g1 or /g2, so I wrote an iRule to remove /g1 or /g2, retain the remainder of the URI, and send the request to the appropriate pool. The initial request is sent to the correct pool and a cookie is set. Then the application has a dropdown list and when selected the application sends the request to qa-example.com/[query parameters]. The cookie value is the same as the initial request to /G1 or /G2, but the dropdown request is sent to the default pool.
How can I maintain persistence to the /G1 pool member or /G2 member?
ltm virtual qa-example.com_443_vs {
description
destination 10.206.57.3:https
ip-protocol tcp
mask 255.255.255.255
persist {
sso_cookie_60_minute_timeout {
default yes
}
}
pool qa-example.com_443_pool
profiles {
dos { }
http { }
internal-encrypt-server {
context serverside
}
tcp { }
tcp_analytics_collection { }
tlsv1.2client_2020 {
context clientside
}
}
rules {
snat_to_vip_rule
_acl_rule
qa-example.com_groups_rule
}
source 0.0.0.0/0
translate-address enabled
translate-port enabled
vs-index 74
}
ltm pool qa-example.com_443_pool {
description
members {
qa-example.com-01:https {
address 10.206.96.50
session monitor-enabled
state up
}
}
monitor https
}
ltm pool qa-example.com-g1_443_pool {
description
members {
ip-98.31-tcm-03web4-001.qa-example.com:https {
address 10.206.98.31
session monitor-enabled
state up
}
ip-98.32-tcm-03web4-002.qa-example.com:https {
address 10.206.98.32
session monitor-enabled
state down
}
}
monitor https
}
ltm pool qa-example.com-g2_443_pool {
description
members {
tcm-03Wweb-003_96.77:https {
address 10.206.96.77
session monitor-enabled
state up
}
tcm-03Wweb-004_96.77:https {
address 10.206.96.78
session monitor-enabled
state up
}
}
monitor https
}
ltm persistence cookie sso_cookie_60_minute_timeout {
app-service none
cookie-name sso.example.com
defaults-from cookie
expiration 1:0:0
}
ltm rule qa-example.com_groups_rule {
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] contains "/g1/" } {
log local0. "g1 Original URI: [HTTP::uri]"
set uri "/[getfield [HTTP::uri] "/" 2]/"
HTTP::uri [string map " $uri / " [HTTP::uri]]
log local0. "g1 New URI: [HTTP::uri]"
pool qa-example.com-g1_443_pool
persist cookie insert sso.example.com
}
if { [string tolower [HTTP::uri]] contains "/g2/" } {
log local0. "g2 Original URI: [HTTP::uri]"
set uri "/[getfield [HTTP::uri] "/" 2]/"
HTTP::uri [string map " $uri / " [HTTP::uri]]
log local0. "g2 New URI: [HTTP::uri]"
pool qa-example.com-g2_443_pool
persist cookie insert sso.example.com
}
}
when LB_SELECTED {
Once pool member has been selected log it.
log local0. "[HTTP::uri] sent to [LB::server addr]"
}
}
It is the same cookie applied in all conditions. You may change 'persist cookie insert sso.example.com' to 'persist cookie' to rely on F5 bigip cookie or use different specific cookies.
Also, make sure that oneconenct is enabled or LB::detach is used in iRule.
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