Forum Discussion
IRule to select Virtual server based on Incoming URI
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
switches for larger data sets.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
