Forum Discussion
Eduardo_Saito_1
Nimbostratus
Sep 13, 2007Insane behaviour while selecting pool
Hello guys,
This week while troubleshooting an iRule made by another developer, an insane behaviour starded to happen.
The iRule is prety simple. The goal is to redirect to 3 pools (poolA, poolB and poolC) based on URI (eg. www.abc.com/uriA, uriB, and so on), and if none is matched, go to the default pool used by the Virtual Server.
The other goal is to remove the folder from the URI, so a request www.abc.com/uriA/test.html will look just as www.abc.com/test.html.
Here's the problem:
When you access www.abc.com/somethingelse/crazy.html, sometimes it goes to the default pool (working ok) and sometimes it goes to the poolA (wrong)!!!!
Even worst, on the webserver the uri looks unchanged. Which is crazy talk because if it is something wrong with the pool selection, it would at least remove the /somethingelse/ from it.
Here's the Problematic CODE:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/uriA/*" {
HTTP::uri [string range [HTTP::uri] 5 end]
pool poolA
}
"/uriB/*" {
HTTP::uri [string range [HTTP::uri] 5 end]
pool poolB
}
"/uriC/*" {
HTTP::uri [string range [HTTP::uri] 5 end]
pool poolC
}
}
}
Recently I've made the rule from the scratch and it seems working ok, but what was the problem with the original rule?
MyCode (THIS iRule Works OK - BUT WHAT'S THE PROBLEM WITH THE OLD CODE?):
when HTTP_REQUEST {
set uri_original [string tolower [HTTP::uri]]
if {$uri_original starts_with "/uriA/"}{
HTTP::uri [string range [HTTP::uri] 5 end]
pool poolA
} elseif {$uri_original starts_with "/uriB/"}{
HTTP::uri [string range [HTTP::uri] 5 end]
pool poolB
} elseif {$uri_original starts_with "/uriC/"}{
HTTP::uri [string range [HTTP::uri] 5 end]
pool poolC
} else {
pool default_pool_from_virtualserver
}
}
- JRahm
Admin
There is no default condition on your switch statement:when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/uriA/*" { HTTP::uri [string range [HTTP::uri] 5 end] pool poolA } "/uriB/*" { HTTP::uri [string range [HTTP::uri] 5 end] pool poolB } "/uriC/*" { HTTP::uri [string range [HTTP::uri] 5 end] pool poolC } default { pool default_pool_from_virtualserver } } }
- Eduardo_Saito_1
Nimbostratus
hello citizen. - JRahm
Admin
See this thread regarding your strange behavior: - Eduardo_Saito_1
Nimbostratus
Thanks citizen!
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