Forum Discussion
That will help. but here's the thing. On the virtual servers for each of those SIte's i also have a redirect to a specific login URI. Can you redirect to a pool and issue the appropriate redirect as part of the same iRUle ?
for eg when a user types in https://siteA.domain.com , pool SiteA needs to be selected and the user needs to be redirected to "https://siteA.domain.com/TC/welcome.msv" and when a user ttypes in https://siteB.domain.com, pool SiteB needs o be selected and user needs to be redirected to http://siteB.domain.com/Login/login.apsx
I started out along the path of redirecting to pools based on the URL , but did not know how to issue the redirects
- strain17Oct 03, 2016Nimbostratus
For redirects, you can either use "HTTP::redirect" or "HTTP::respond".
 
https://clouddocs.f5.com/api/irules/HTTP__redirect.html https://clouddocs.f5.com/api/irules/HTTP__respond.html
 
For the trigger, something that checks for either the HTTP::path or HTTP::uri would work. Example"
 
switch -glob [string tolower [HTTP::uri]] { "" - "/" { HTTP::redirect "https://[HTTP::host]/TC/welcome.msv" } }
From your initial description, it doesn't seem like you are sharing a single virtual server with multiple pools. It looked like a virtual server which redirects to other virtual servers. So, if that is the cause, the default pool (if one is set) for each of the virtual servers should serve the request to appropriate pools.
 
- Karthik_Krishn1Oct 03, 2016Cirrostratus
Actually i do want to use a single virtual server to redirect to other pools and at the same time perform the redirect to the appropriate URL once the pool is selected. Currently the way these are setup is a single VS for each site.
The rule i was going to use for pool selection is as below. Is it possible to do the redirect within this rule.
when HTTP_REQUEST { if {[HTTP::uri] contains "siteA.domain.com" } { log local0. "SiteA Access" pool vs_SiteA_prod_pool_pool } elseif {[HTTP::uri] contains "SiteB.domain.com" } { log local0. "SiteB Access" pool vs_SiteB_prod_pool } elseif {[HTTP::uri] contains "SiteC.domain.com" } { log local0. "SiteC Access" pool vs_kronos_prod_pool } elseif {[HTTP::uri] contains "SiteD.domain.com" } { log local0. "SiteD Access" pool vs_SiteD_prod_pool } else { log local0. "SiteA" pool vs_SiteA_prod_pool } } }
- strain17Oct 03, 2016Nimbostratus
Without fully understanding 100% what it is you are trying to do still (because URL redirection is independent of the actual pool selection). Here is a modified (very crude) example of what you can do with your iRule above:
when HTTP_REQUEST { if {[HTTP::uri] contains "siteA.domain.com" } { log local0. "SiteA Access" pool vs_SiteA_prod_pool_pool if {[HTTP::uri] == "" || [HTTP::uri] == "/"} {HTTP::redirect "https://[HTTP::host]/TC/welcomeA.msv"} } elseif {[HTTP::uri] contains "SiteB.domain.com" } { log local0. "SiteB Access" pool vs_SiteB_prod_pool if {[HTTP::uri] == "" || [HTTP::uri] == "/"} {HTTP::redirect "https://[HTTP::host]/TC/welcomeB.msv"} } elseif {[HTTP::uri] contains "SiteC.domain.com" } { log local0. "SiteC Access" pool vs_kronos_prod_pool if {[HTTP::uri] == "" || [HTTP::uri] == "/"} {HTTP::redirect "https://[HTTP::host]/TC/welcomeC.msv"} } elseif {[HTTP::uri] contains "SiteD.domain.com" } { log local0. "SiteD Access" pool vs_SiteD_prod_pool if {[HTTP::uri] == "" || [HTTP::uri] == "/"} {HTTP::redirect "https://[HTTP::host]/TC/welcomeD.msv"} } else { log local0. "SiteA" pool vs_SiteA_prod_pool } }
I personally would use the switch statement for this.
- JinshuOct 04, 2016Cirrus
Hi Karthik,
I'm sorry for responding late. I think, Vernon has already answered your question.
Cheers,
-Jinshu