Forum Discussion
Hille_de_Graaf_
Nimbostratus
Mar 25, 2008Simplify iRule
I have an iRule which would look at the content of the HTTP-header and loadbalance on behalve of that content.
Is there a more efficient way to build an iRule with the same results as the example...
The_Bhattman
Nimbostratus
Mar 25, 2008There are 2 ways I can see this work.
1) Using SWITCH
You can use the switch statement
when HTTP_REQUEST {
switch [HTTP::uri] {
"ACCBPMv1" {pool xml-fw }
"ACCTVIv1" { pool xml-fw }
"ACCTDSv1" { pool xml-fw }
"BPMv1" { pool xml-fw }
"TVIv1" { pool xml-fw }
"DVSv1" { pool xml-fw }
}
}or
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"ACC*" {pool xml-fw }
"BPMv1" { pool xml-fw }
"TVIv1" { pool xml-fw }
"DVSv1" { pool xml-fw }
}
}or
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"*v1" {pool xml-fw }
}
}You would then set the virtual server to the default pool to ws-accxml for any of the switch irules listed above.
2) Using Datagroup the solution looks a bit cleaner.
class uricontains {
"ACCBPMv2"
"ACCBPMv1"
"ACCTVIv1"
"ACCTDSv1"
"BPMv1"
"TVIv1"
"DVSv1"
}
when HTTP_REQUEST {
if { [matchclass [HTTP::uri] contains $::uricontains] } {
pool xml-fw
} else {pool xml-accxml }
}Hope this helps
/CB
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
