Forum Discussion
iRule Path Routing to pool review.
Hello I have a few designated paths in which I would like to direct to a specific pool otherwise to a default pool. Here is the script that I have came up with using a combination of others I have found on the site. Can you help me confirm this is correct and will work? This is also for HTTPS, so do I need to change "when HTTP_REQUEST" to "when HTTPS_REQUEST"?
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] equals "/a.php" or [string tolower [HTTP::uri]] starts_with "/b.php"} or [string tolower [HTTP::uri]] starts_with "/c/*"} { pool /Common/pool-A_pool } else { pool Common/pool-B_apool }
}
Thanks for your time.
Hi viziony,
I think you could use a switch statement rather than a lot of or conditions. This iRule should work for you.
Instead of starts_with, I use a wildcard *. You could also use HTTP::path instead of HTTP::uri.when HTTP_REQUEST { switch -glob -- [string tolower [HTTP::uri]] { "/a.php*" - "/b.php*" - "/c.php*" { pool my_pool_ABC } default { pool my_pool_XYZ } } }
Let me know if this one works for you, or it needs adjustments.
KR
Daniel- vizionyCirrus
Thank you Dan for the quick reply! Will update this thread once I test it out.
- vaibhavCirrostratus
Yep switch -glob is best option for you and for more details on the various options/functions available to switch pool you can refer below documentation it is a good read
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