Forum Discussion
iRule to redirect based on availability
Hi There, I am looking to implement a redirect on web traffic based on the availability of a specific web pool.
I have 3 pools which are front ended by one VIP that uses an iRule to direct traffic to the pools based on virtual directories.
So example is, if URI contains /A goto pool1, if /B goto pool2. But I want to have a conditional redirect on pool3, like if URI contains /C then goto pool3 , but if pool3 members are all offline, then HTTP redirect to
Can someone please let me know if this can be achieved?
thanks J
5 Replies
- nitass
Employee
if URI contains /C then goto pool3 , but if pool3 members are all offline, then HTTP redirect to
you can use active_members command to check number of pool3 active members before sending traffic to. if all is down, you can send http redirection using either HTTP::redirect or HTTP::respond command.
active_members
https://devcentral.f5.com/wiki/iRules.active_members.ashx - Samir_Jha_52506
Noctilucent
Hi, I agree with @nitass comments. You need to verify 1st Pool_C status. I guess, it require two iRule to check the connection. Status of Pool C. If it is up then it traffic will go to 2nd iRule.
Rule 1(make 1st iRule)
when HTTP_REQUEST { if { [active_members pool_c] < 1 } { HTTP::redirect http://failoverurl return } }Rule 2. Redirect traffic based on the condition.
when HTTP_REQUEST { set uri [string tolower [HTTP::path]] switch -glob $uri { "/A/" { pool A } "/B/" { pool B } "/C/" { pool C } } }Hope it will work..
- jpars_136473
Nimbostratus
Thanks for the replies.
I don't want to affect the other pools though. In your example, wont your 1st iRule take precedence, in which case if pool3 is offline then it will redirect all requests and not invoke the second iRule?
I'm looking to only redirect if the request contains /C, other requests should always go to the other pools.
thanks J
- nitass
Employee
I'm looking to only redirect if the request contains /C, other requests should always go to the other pools.
e.g.
when RULE_INIT { pool names set static::poola "a" set static::poolb "b" set static::poolc "c" set static::pooldefault "default" } when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/a/*" { pool $static::poola } "/b/*" { pool $static::poolb } "/c/*" { if { [active_members $static:poolc] > 0 } { pool $static::poolc } else { pool $static::pooldefault } } default { do something } } } - jpars_136473
Nimbostratus
Awesome. Thank you!!
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