Forum Discussion
F_Ducloux_29246
Nimbostratus
Aug 04, 2008iRule help request
Hi Guys, I'm very new at this and I just joined a company that is using F5 BigIPs and i got asked to investigate if I could write a new rule to do this:
I have several virtual servers called
apache1.qa1.ee.com
apache2.qa1.ee.com
apache3.qa1.ee.com
apache1.qa2.ee.com
apache2.qa2.ee.com
apache3.qa2.ee.com
then i have an iRule related to that VS that says
apache1.ee.com
when HTTP_REQUEST {
if { [HTTP::host] contains "qa1" } {
pool apache1.qa1.ee.com
} elseif { [HTTP::host] contains "qa2" } {
pool apache1.qa2.ee.com
}
}
and then again the same thing for apache2.. and i have about 210 virtual servers. with 210 iRules,
is there anyway that i can get the the VS name into a variable then parse it and only get the first part and then use that to create only one rule for all of the servers?
something like this
generic rule
when HTTP_REQUEST {
if { [HTTP::host] contains "qa1" } {
pool $VS.qa1.ee.com
} elseif { [HTTP::host] contains "qa2" } {
pool $VS.qa2.ee.com
}
Thanks
Fernando
- Nicolas_Menant
Employee
Hi, - If you are always triggering off of the second part of the virtual and the mapping is always to apache1."field 2".ee.com, then you can use getfield to extract that value and then dynamically build the pool name
when HTTP_REQUEST { set token [getfield [HTTP::host] "." 2] pool "apache1.$token.ee.com" }
when HTTP_REQUEST { set token [getfield [HTTP::host] "." 2] if { [catch { pool "apache1.$token.ee.com" } ] } { log local0. "Error using pool apache1.$token.ee.com" } else { do some error handling in here. } }
- F_Ducloux_29246
Nimbostratus
wow thanks joe!! - F_Ducloux_29246
Nimbostratus
i forgot to say.. - Glad to help! Please feel free to post any questions that come up in the mean time.
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