The first line looks fine, but I did make the mistake of assuming that you could use the IP::addr command in this way. Since the IP::addr command takes two arguments, you won't be able to use it in a switch statement. That means you'll have to use a series of if/else comparisons if you want to compare network ranges with multiple destinations. Since your example only uses a single pool as a destination, you could use the or command instead of multiple ifs.
So, if you're just comparing single IP addresses, you could do so like:
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] eq "/foo/"} {
switch [IP::remote_addr] {
10.12.126.248 -
10.12.126.249 -
10.12.126.250 -
10.24.69.2 -
default {
pool FOO.com-80
}
}
} elseif {[IP::addr [IP::remote_addr] equals 10.0.0.0/255.0.0.0] } {
HTTP::redirect "http://www.NEW.com"
}
}
If you need to compare network ranges, and therefore need the IP::addr command, you would want something more like:
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] eq "/foo/"} {
if {([IP::addr [IP::remote_addr] equals 10.12.126.248/255.255.255.255]) or
([IP::addr [IP::remote_addr] equals 10.12.126.249/255.255.255.255]) or
([IP::addr [IP::remote_addr] equals 10.12.126.250/255.255.255.255]) or
([IP::addr [IP::remote_addr] equals 10.24.69.2/255.255.255.255])
} {
pool FOO.com-80
}
} elseif {[IP::addr [IP::remote_addr] equals 10.0.0.0/255.0.0.0] } {
HTTP::redirect "http://www.NEW.com"
}
}
Hopefully this helps,
Colin