Forum Discussion
Please help in creating a content switching irule
Below is the requirement:- If url https://xyz.abc.com contains below switches ; it should point to pool1:-
/providerportal1/* - proxy to pool1 /Resources/* - proxy to pool1 /provider_get/* - proxy to pool1 /exadmin/* - proxy to pool1
else if url contains below switch;it should point to pool2
/portal/* - proxy to pool2
example :
1.https://xyz.abc.com/Resources/ >>>pool1 2.https://xyz.abc.com/exadmin/ >>>pool1 3.https://xyz.abc.com/portal/ >>>pool2
2 Replies
- Hannes_Rapp
Nimbostratus
Give it a shot.
when HTTP_REQUEST { if {[HTTP::host] == "xyz.abc.com"} { switch -glob [HTTP::uri] { "/providerportal1/*" - "/Resources/*" - "/provider_get/*" - "/exadmin/*" { pool pool1 } "/portal/*" { pool pool2 } } } } - Eric_St__John
Employee
I would make a couple of minor changes for efficiency(HTTP::path rather than HTTP::uri), and to deal with the possibility of upper/lower case requests(string tolower):
when HTTP_REQUEST { if {[string tolower[HTTP::host]] == "xyz.abc.com"} { switch -glob [string tolower[HTTP::path]] { "/providerportal1/*" - "/resources/*" - "/provider_get/*" - "/exadmin/*" { pool pool1 } "/portal/*" { pool pool2 } } } }
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