Forum Discussion
Karthik_Krishn1
Cirrostratus
Oct 03, 2016IRule to select Virtual server based on Incoming URI
Hello,
I am trying to setup an irule such that traffic based on certain URL's is directed towards the appropriate virtual servers. Essentialy we have mutliple URL's " siteA.domain.com" , "siteB....
VernonWells
Employee
Oct 03, 2016It 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.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