Forum Discussion
Base Path URL Redirect to Specific Pool
Hi there,
I'm new to this forum and looking for some help, looking to create irule that will allow base path URL to redirect traffic to a certain pool.
example
incoming url https://xxxx.test.com/tester redirect to pool 1
incoming url https://xxx.test.com/tester/tester122 redirect to pool 2
Thanks,
Phong
- Heino
Cirrus
when HTTP_REQUEST { set vurl [HTTP::host][HTTP::path] if { $vurl starts_with "xxx.test.com/tester/tester122"} { pool pool_name_a } elseif { $vurl starts_with "xxx.test.com/tester"} { pool pool_name_b } else { # no change to traffic } }
Probably something along these lines, with the more specific one first, as the less specific one otherwise will catch both.
Another point, if you have a lot of cases, like 20+, then it'd be a good idea to change to from repeated if statements to data groups.
If you don't need to test for domain you can remove the [HTTP::host] from the variable and the if statements
A lot of the time you can find inspiration to irules on clouddocs. For me "if" is bit more versatile, so I'll typically use it for these shorter rules. If you have a longer rule where you test a lot on the same variable then the Switch could be better.
The better advice would probably be to steer you towards http policies that can do this in a more user friendly/intuitive way... but I like irules.
- Bruce0279
Nimbostratus
thanks Heino for your help, I'll give it a shot
Phong
- spalande
Nacreous
Something sort of below. Modify the pool names accordingly
when HTTP_REQUEST { set baseuri [lindex [split [string tolower [HTTP::uri]] "/"] 1] if { [HTTP::uri] eq "/$baseuri" } { pool pool_1 } else { pool pool_2 } }
- Bruce0279
Nimbostratus
thank you Sanjay for your support!
- Former Member
- if you got an answer please Select As Best or Upvote contributing answers.
Thanks.
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