Forum Discussion
irule help based on uri
Hi
You could do something like
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/live"}{
pool pool_live
} elseif {[HTTP::uri] starts_with "/test"}{
pool pool_test
}
}- DanS92Sep 03, 2019
Cirrus
Another way would be with a Local Traffic Policy instead of an iRule. Under Local Traffic > Policies > Policy List, create a new policy. You'd need a rule in the policy like this for the first request:
The rule for the second URI would be built the same way. Then apply the policy to the VIP.
- cymru81Sep 04, 2019
Altocumulus
Im sorry to move the goalposts but my brief has changed to the following now:
we have one VIP that hostname site.abc.com resolves to, if user visits https://site.abc.com/live it should redirect to pool "pool_live" changing the ur toi "/live_site". If user visits https://site.abc.com/test it should redirect to pool "pool_test" changing the uri to /test_site.
Is this achievable?
- Sep 04, 2019
Hi cymru81,
iRule:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.abc.com" } { switch -glob [string tolower [HTTP::uri]] { "/live" { HTTP::uri "/live_site" pool pool_live } "/test" { HTTP::uri "/test_site" pool pool_test } } } }iRule with redirect:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.abc.com" } { switch -glob [string tolower [HTTP::uri]] { "/live" { HTTP::redirect "https://site.abc.com/live_site" pool pool_live } "/test" { HTTP::redirect "https://site.abc.com/test_site" pool pool_test } } } }If the HTTP::host is not site.abc.com, you can reject requests.
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
