Forum Discussion
iRule to Select pool by parsing
Hello, I want to Create an Irule that will forward a request coming to Site1.website.com to pool Site1. I want it to be generic so if i add another pool named SiteXYZ and assign another DNS record named SiteXYZ.website.com it will also take it. I am guessing it will be something like this:
when HTTP_REQUEST { set content [HTTP::host] set PoolName [split $content "."]
if { pool $PoolName[1] Exist } pool $PoolName[1] else return error of somekind
will that work?
2 Replies
- John_Alam_45640Historic F5 Account
Name the pools site1 and site2.... siteX..
it can be as easy as this.when HTTP_REQUEST { extract the first part of hostname. set poolname [getfield [HTTP::header host] "." 1] pool $poolname }To make sure you don't send user to an undefined pool name do this:
when HTTP_REQUEST { extract the first part of hostname. set poolname [getfield [HTTP::header host] "." 1] if { [catch {pool $poolname} id ] } { You can find this in the local traffic log from GUI or via : tail /var/log/ltm log local0. "Pool name $poolname does not exist yet." } } - shlomi_133455
Nimbostratus
Thanks a lot, this is exactly what i was looking for. just Small FYI to whoever will use it in the future... Pools are case Sensitive so you need to take it under consideration when creating the redirect.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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