Forum Discussion
Rob_Wotton_8024
Nimbostratus
Oct 21, 2009Multiple Pool Redirection Based on IP
Hi
I am struggling with an iRule at the moment, in simple English when the URI starts with /product1 and is from IP address 1.1.1.1 we need to use pool product1-CustomerA. If the URI st...
hoolio
Cirrostratus
Oct 21, 2009Hi Rob,
That looks pretty close. Can you try this version with some debug logging added? I used the -glob flag on switch to group of few of the cases together. The curly braces also needed a tweak.
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method] request to [HTTP::host][HTTP::uri]"
if { [IP::addr [IP::client_addr]/32 equals 1.1.1.1] } {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched IP check for 1.1.1.1"
switch -glob [string tolower [HTTP::uri]] {
"/product[1-3]" {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched /product1-3 check"
pool product1-CustomerA
}
default {
log local0. "[IP::client_addr]:[TCP::client_port]: No match on /product1-3 check"
pool standardpool-CustomerA
}
}
} else {
switch -glob [string tolower [HTTP::uri]] {
"/product1" {
log local0. "[IP::client_addr]:[TCP::client_port]: No IP match. Matched /product1 check"
pool product1
}
"/product[2-3]" {
log local0. "[IP::client_addr]:[TCP::client_port]: No IP match. Matched /product2-3 check"
pool product2
}
default {
log local0. "[IP::client_addr]:[TCP::client_port]: No IP match. No product check"
pool standardpool-CustomerB
}
}
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects