Forum Discussion
Switch Irule
I need to create an IRULE that takes a certain uri and redirects based on the start to specific pools. Would like to do this in switch format.
Any suggestions.
3 Replies
- Ryannnnnnnnn
Altocumulus
Hi mate,
You can give something like the following a shot:
when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] switch -glob $uri { "/somepath/dir1*" - "/somepath/dir2*" { pool POOL_my.site.com-443 } default { pool POOL_your.site.com-443 } } } - gpayne_144568
Nimbostratus
Ok here is what I have. It is very ineffecient and I want to change it to work. I know I could do and if/elseif to clean it up. Would prefer to do switch with the log statement.
Change debug to 1 to enable loggingwhen HTTP_REQUEST { set static::DEBUG 0
if {[string tolower [HTTP::path]] starts_with "/XXXX"}{ pool XXX---xxxx-x-xxxxx.xxxx.xxxx.xxx---POOL---8095 } if {[string tolower [HTTP::path]] starts_with "/xxx/xxxx"}{ pool XXX---xxxx-x-xxxxx.xxxx.xxxx.xxx---POOL---8095 } if {[string tolower [HTTP::path]] starts_with "/xxx/xxxx"}{ pool XXX---xxxx-x-xxxxx.xxxx.xxxx.xxx---POOL---8095 } if {[string tolower [HTTP::path]] starts_with "/xxx/xxxx"}{ pool XXX---xxxx-x-xxxxx.xxxx.xxxx.xxx---POOL---8095 if { $static::DEBUG != 0 } { log local0. "for [IP::client_addr] Pool was selected and directed to port 8095" } } }
- Ryannnnnnnnn
Altocumulus
something like this?
when HTTP_REQUEST { set static::DEBUG 1 set uri [string tolower [HTTP::uri]] switch -glob $uri { "/XXXX*" - "/xxx/xxxx*" { if { $static::DEBUG != 0 } { log local0. "for [IP::client_addr] Pool was selected and directed to port 8095" } pool XXX---xxxx-x-xxxxx.xxxx.xxxx.xxx---POOL---8095 } default { pool my.default.pool } } }
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