Users router will direct all HTTP traffic to external interface( external vlan ) of my F5 LTM . on this external vlan i have Vs listening for HTTP traffic & i need to do the below :
when CLIENT_ACCEPTED {
Save VS default pool name
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
switch [string tolower [URI::host [HTTP::uri]]] {
youtube.com -
www.youtube.com -
4shared.com -
www.4shared.com -
rapidshare.com -
www.rapidshare.com {
pool cache_pool
}
default {
pool $default_pool
}
}
}
Q1:****Vs is 0.0.0.0 & port 80 . router will forward HTTP traffic to LTM so i think this means that it is transparent & i can use what you provided , right ?
Q2) set default_pool [LB::server pool] = this is setting up a variable (default_pool) that is referenced further down the iRule. So it will record what the default pool is associated with the VS and then refer requests onto this if they’re not in the list of URLs. So the command would then be “pool http_pool” or whatever is the pool’s name.
Q4) string tolower converts the whole host and URI into lower case - so, in effect, makes the switch command case insensitive. You probably don’t need the HTTP::uri but I would use it for neatness so the whole URL is interrogated. May be wrong of course.
I’m not an iRule expert I’m afraid but hope this is useful / correct.
That’s a great explanation Nathan. One more note: I used URI::host to parse the host name from a fully qualified URL in the URI. If the client is making requests through LTM to a web proxy, they would use a fully qualified URI. Else, if they’re going through a transparent proxy, the URI would be relative and you’d want to check for the host name of the request in the host header using [HTTP::host] instead of [URI::host [HTTP::uri]].