Forum Discussion
VernonWells
Oct 03, 2016Employee
It looks from your original post that you are simply trying to make a pool selection based on the incoming Host header. For more details on the Host header, I encourage you to read the "Elaboration" section of this iRule recipe:
The
virtual
command selects a BIG-IP Virtual Server by name. That's almost certainly not what you want (though it could be, if you had differing profiles attached to various Virtual Servers; but in that case, it usually makes more sense to map the DNS hostnames to differing IPs, one per Virtual Server). Again, assuming that you wish to select a BIG-IP Pool based on the incoming Host header value:
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"www.abc.com" {
pool abc_com
}
"www.def.com" {
pool def_com
}
"www.alpha.com" -
"www.beta.com" {
pool alphabet
}
}
}
To understand the dash case, see the Elaboration section of "Analysis" section of this recipe:
People often put in a "default" case, but you generally do not need to do so. If no
switch
case matches, the default configuration of the Virtual Server will be used, including whatever Pool is attached to the Virtual Server.
If you have a large number of cases, then you should consider using a Data-Group:
Data-Groups are more efficient than
switch
es for larger data sets.