Forum Discussion
Name Based Virtual Hosting irule efficiency
From my experience (as we do something similar in my organization), we've used data groups to handle all this (and parse the values to get information we need).
Regarding how to interact with data groups, this wiki page gives links to the class, findclass and matchclass functions, which should help guide you in the right direction.
For us, we sometimes use a format like
name1:value1|name2:value2|...
as the data group value (with a hostname or uri prefix as the name on the data group record). From there we parse out the parameters we need. So for example
- DG Record Name:
example.com
- DG Record Value:
pool:my_pool|host:www.mynewhost.com
So in our iRule, we would check for
example.com
in the data group
set host [string tolower [HTTP::uri]]
if { [class match $host equals DATA_GROUP_NAME] } {
set param [class match -value $host equals DATA_GROUP_NAME]
Add some checking for data integrity if necesary
set params [split $param "|"]
set pool [getfield [lsearch -inline -glob $params "pool:*"] ":" 2]
set host [getfield [lsearch -inline -glob $params "host:*"] ":" 2]
Set the pool
pool $pool
Change the host
HTTP::host $host
}
It's a simple example, and depending on the amount of traffic, may not be the most efficient way of doing it, but I've found it's the simplest, as we just add a record to the data group and don't have to touch the iRule.
Hope this helps.
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