Forum Discussion
iRule to redirect and select node/pool
I am working on an irule that will redirect users based on the HTTP::path that they enter. The prod rule will direct them to separate pools of servers and redirect them to the same URL. Here is an example of the URL they would be typing.
http://app.com/ http://app.com/def http://app.com/ghi
Based on the path they use it will send them to the appropriate pool of nodes
abc = abc_pool def = def_pool ghi = ghi_pool
Everyone will end up being redirected to the same URL.
Redirect to: http://app.com/do/login
Here is my rule but it seems to be ignoring the pool or node selection.
when HTTP_REQUEST {
if {[HTTP::path] eq "/"} {
HTTP::redirect "https://app.com/do/login/"
pool "abc_pool"
}
elseif {[HTTP::path] eq "/def"} {
HTTP::redirect "https://app.com/do/login"
pool "def_pool"
}
}
Please take it easy on me I am completely new to iRules and am learning. Any assistance is greatly appreciated.
- Jer-O
Cirrus
I'm not sure if this logic can work as it stands. The reason the pools are ignored is that you are just redirecting the user back to the same virtual server, where the new URI will not trigger the pool select, because there is no condition for eq "/do/login" once they are redirected. Then the problem becomes how to differentiate between someone who started at / and someone who started at /def.
You can solve this by having different login pages for each pool of servers so that you can capture the difference once they are redirected.
when HTTP_REQUEST { if { [HTTP::uri] eq "/" } { HTTP::redirect "https://app.com/do/login1/" } elseif { [HTTP::uri] eq "/def" } { HTTP::redirect "https://app.com/do/login2/" } elseif { [HTTP::uri] starts_with "/do/login1/" } { pool "abc_pool" } elseif { [HTTP::uri] starts_with "/do/login2/" } { pool "def_pool" } else { return } }
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