Forum Discussion
some basic irule logic... where am I going wrong?
Hi,
I've got an irule doing the following:
switch -glob [HTTP::uri] {
"/con1" -
"/con1/*" {
pool pool-1
return
}
"/con2" -
"/con2/*" {
pool pool-2
return
}
However, for all sorts of reasons that I won't get into, I need to alter the above to punt anything for /con1/con2/* to pool-2
I've tested this and consistently get feedback from our testers to say "no dice". Soem basic browser tests would seme to confirm this.
I place my context switches in the following order:
"/con1/con2" -
"/con1/con2* -
"/con2" -
"/con2/*" {
pool pool-2
return
}
"/con1" -
"/con1/*" {
pool pool-1
return
}
and even tried string substitution like so to no avail:
"/con2" -
"/con2/*" -
"/con1/con2/*" {
HTTP::uri [string map { "/con1/con2/" "/con2/" } [HTTP::uri]]
pool pool-2
return
}
Is the /con1/* or /con1/ overriding the first context switch and/or all subsequent switches? It seems to work fine if I use something along the lines of:
"/con1" -
"/con1/*" {
pool pool-1
return
}
"/con1-3" -
"/con1-3/*" {
pool pool-3
return
}
Thanks!
- nitass
Employee
this is my testing.[root@ve10:Active] config b virtual bar list virtual bar { snat automap destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set uri [HTTP::uri] switch -glob -- [string tolower $uri] { "/con1/con2*" - "/con2*" { pool pool-2 } "/con1*" { pool pool-1 } } } when SERVER_CONNECTED { log local0. "URI $uri | Pool [LB::server pool] | [IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] | [IP::local_addr]:[TCP::local_port] -> [IP::server_addr]:[TCP::server_port]" } } [root@ve10:Active] config b pool pool-1 list pool pool-1 { members 200.200.200.101:80 {} } [root@ve10:Active] config b pool pool-2 list pool pool-2 { members 200.200.200.102:80 {} } [root@ve10:Active] config cat /var/log/ltm Aug 25 14:56:03 local/tmm info tmm[14353]: Rule myrule : URI /con1 | Pool pool-1 | 172.28.19.80:33020 -> 172.28.19.79:80 | 200.200.200.10:33020 -> 200.200.200.101:80 Aug 25 14:56:07 local/tmm info tmm[14353]: Rule myrule : URI /con1/something | Pool pool-1 | 172.28.19.80:33021 -> 172.28.19.79:80 | 200.200.200.10:33021 -> 200.200.200.101:80 Aug 25 14:56:16 local/tmm info tmm[14353]: Rule myrule : URI /con2 | Pool pool-2 | 172.28.19.80:33022 -> 172.28.19.79:80 | 200.200.200.10:33022 -> 200.200.200.102:80 Aug 25 14:56:26 local/tmm info tmm[14353]: Rule myrule : URI /con2/something | Pool pool-2 | 172.28.19.80:33023 -> 172.28.19.79:80 | 200.200.200.10:33023 -> 200.200.200.102:80 Aug 25 14:56:44 local/tmm info tmm[14353]: Rule myrule : URI /con1/con2 | Pool pool-2 | 172.28.19.80:33024 -> 172.28.19.79:80 | 200.200.200.10:33024 -> 200.200.200.102:80 Aug 25 14:56:53 local/tmm info tmm[14353]: Rule myrule : URI /con1/con2/something | Pool pool-2 | 172.28.19.80:33025 -> 172.28.19.79:80 | 200.200.200.10:33025 -> 200.200.200.102:80
- Ottimo_Massimo1
Nimbostratus
Hi Nitass, - nitass
Employee
I wonder if the "/con1" - is overriding everything else in my irule - Ottimo_Massimo1
Nimbostratus
thanks Nitass. This request was ditched in the end. I'll need to test it in a lab to confirm my suspicions about that "/con1" - condition - Ottimo_Massimo1
Nimbostratus
thanks Nitass. This request was ditched in the end. I'll need to test it in a lab to confirm my suspicions about that "/con1" - condition
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