annielee_13548
May 13, 2015Nimbostratus
Solved
irules optimization
Hi,
I am trying to optimize the irules below (to a for each loop, if possible) im modifying and need some programming help 🙂
if { ([HTTP::host] contains "env-1") || ([HTTP::host] contains "1.1.1.1") } {
log local0. "ENV-1, HEADER=[HTTP::header Host], URI=[HTTP::uri]"
set AA_pool env-1_AA_11
set BB_pool env-1_BB_88
elseif { ([HTTP::host] contains "env-2") || ([HTTP::host] contains "1.1.1.2") } {
log local0. "ENV-2, HEADER=[HTTP::header Host], URI=[HTTP::uri]"
set AA_pool env-2_AA_22
set BB_pool env-2_BB_88
elseif { ([HTTP::host] contains "env-3") || ([HTTP::host] contains "1.1.1.3") } {
log local0. "ENV-3, HEADER=[HTTP::header Host], URI=[HTTP::uri]"
set AA_pool env-3_AA_33
set BB_pool env-3_BB_88
elseif......til env-10
Is that possible ?? Thanks in advance.
can you try something like this?
when HTTP_REQUEST { switch -glob [HTTP::host] { "*env-1" - "1.1.1.1*" { Do something } "*env-2*" - "1.1.1.2*" { Do something } default { Do something } } }