Forum Discussion
iRule for URI Switching Nested Inside of Hostname Switching
Is it possible to nest URI switching inside hostname switching? If so, does someone have any links or suggestions I can try? I found a hostname switching example (below, after uri example). However, instead of switching to a pool, i would like the irule to switch to code that URI switches. Instead of "pool site1_pool" in the hostname switching example below, I would like to know if you can replace "pool site1_pool" with something similar to this:
URI switching example
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri] ] {
"/path1/file.jpg" { pool POOLNAME1 }
"/path2/file.jpg" { pool POOLNAME2 }
default { drop } } }
hostname switching example
when HTTP_REQUEST {
Check requested host header (set to lowercase)
switch [string tolower [HTTP::host]] {
"www.site1.com" {
pool site1_pool
}
"www.site2.com" {
pool site2_pool
}
default {
pool default_pool
}
} }
3 Replies
- Kevin_Stewart
Employee
Absolutely possible.
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "www.domain.com" { switch -glob [string tolower [HTTP::uri]] { "/app1*" { log local0. "app1" } "/app2*" { log local0. "app2" } "/app3*" { log local0. "app3" } default { drop } } } default { drop } } } - Dave_21103
Nimbostratus
Thanks Kevin! I'm going to try this in our lab today.
- Dave_21103
Nimbostratus
Kevin, this worked like a champ! Thanks!
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