Forum Discussion
Gary_Bristol_19
Nimbostratus
Dec 15, 2015additional conditions on an irule
i have an iRule that does a check for a home page if it matches then send it to a specific pool.
then i check a External Data Group list for redirection and pool selections or a default pool for none...
Gary_Bristol_19
Nimbostratus
Dec 15, 2015actually i don't think i want the switch -exact on the settting as i have many pool selections that depend on going to a content pool of servers below a certain directory level. I do have some that are more specific that need to go to different places that is why i do a reverse sort on the EDG file.
here is what i was able to come up with..
when HTTP_REQUEST {
Lookup the redirect or pool based upon match_string value
set goto [class match -value [string tolower [HTTP::host][HTTP::path]] starts_with www_ou_edu_redir_class]
if { [string tolower [HTTP::host][HTTP::path]] equals "ou.edu/" }{
HTTP::redirect "http://www.ou.edu/"
} elseif { [string tolower [HTTP::host][HTTP::path]] equals "www.ou.edu/" }{
pool www_ou_edu_cms_servers
} else {
switch [getfield $goto "," 1] {
"pool" { pool [getfield $goto "," 2] }
"redir" { HTTP::redirect [getfield $goto "," 2] }
default { pool ouwww_bostitch }
}
}
}
- Kai_WilkeDec 15, 2015
MVP
The -exact is actually the default value of the [switch] command. I tend to specify this explicitly to avoid confusion. In addition the -exact match would only be used to match the string "pool" or "redir" (aka. [getfield $goto "," 1]) and then fall back to "default". The reson why I'm using the $low_host_path variable is pure performance releated. My example calculates a single time the string "[string tolower [HTTP::host][HTTP::path]]" and your example multiple times. I've moved the [set goto] command into the } else { statement to optimize processing. If the upper redirects are triggering the class command wouln't be executed in this case... So in the end a lot of "hidden" optimizations you shouldn't skip ;-) Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
