Forum Discussion
Guilherme
Nimbostratus
Feb 18, 2020Help with irule structure
Hi sirs, I just wrote a rule that reads a specific HTTP header and saves it to USER_COD and if it has an empty value or PRINT value it should forward the connection to a certain pool, if the this va...
iaine
Nacreous
Feb 18, 2020Hi
Try something like this...
when RULE_INIT {
# 0 - log off
# 1 - log on
set static::debug_user_cod 0
}
when HTTP_REQUEST {
if { $static::debug_user_cod } {
set USER_COD [HTTP::header value "USER_COD"]
}
#Switch through the values of header USER_COD. If a value matches then send to appropiate pool
#if no value matches,including value PRINT or a null value then send to default pool
switch -glob [string tolower [HTTP::header value "USER_COD"]] {
"dg_01" {pool POOL_DG_01}
"dg_02" {pool POOL_DG_02}
"dg_03" {pool POOL_DG_03}
"dg_04" {pool POOL_DG_04}
"dg_05" {pool POOL_DG_05}
"dg_06" {pool POOL_DG_06}
"dg_07" {pool POOL_DG_07}
default {pool POOL_DEFAULT
if { $static::debug_user_cod } {
log local0. "----------------------------------------"
log local0. "src: [IP::client_addr] URL -> [HTTP::host][HTTP::uri] (REQUEST)"
log local0. "Value get on USER_COD: $USER_COD"
log local0. "----------------------------------------"
}
}
}
}
when SERVER_CONNECTED {
if { $static::debug_user_cod } {
log local0. "----------------------------------------"
log local0. "src: [IP::local_addr] - Dst Member: [IP::remote_addr] - USER_COD: $USER_COD"
log local0. "----------------------------------------"
}
}- GuilhermeFeb 18, 2020
Nimbostratus
Hi iaine,
Thank you! I cant test right now but I still with a doubt.. how can I insert the empty value into to the datagroup ? There is some situations that header comes empty or with PRINT value and It must be send to a specific pool, may I use the default condition ?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
