Forum Discussion
Fotios_30046
Nimbostratus
Feb 26, 2010Combine Two Rules Into One
I have two rules that perform the same function but on different domains. If a subfolder of /products is found use a different pool, otherwise use the default. My question is, can these be combined into a single rule and if so, where do I check for the domain? Before the switch or after?
The rules in question.
Rule 1 - Domain 1
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/products*" { pool Altruik-Furniture}
default { pool Furniture-Production-Pool-HTTP }
}
}
Rule 1 - Domain 2
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/products*" { pool Altruik-CarpetOne}
default { pool CarpetOne-Production-Pool }
}
}
- You can do it several ways and the deciding factor is which makes more sense to you. Performance should be equivalent. Either of these should work
when HTTP_REQUEST { switch [HTTP::host] { "www.domain1.com" { switch -glob [HTTP::uri] { "/products*" { pool Altruik-Furniture } default { pool Furniture-Production-Pool-HTTP } } } "www.domain2.com" { switch -glob [HTTP::uri] { "/products*" { pool Altruik-CarpetOne} default { pool CarpetOne-Production-Pool } } } } }
when HTTP_REQUEST [ if { [HTTP::uri] starts_with "/products" } { switch [HTTP::host] { "www.domain1.com" { pool Altruik-Furniture } "www.domain2.com" { pool Altruik-CarpetOne } } } }
- hoolio
Cirrostratus
I like the last option, but just be sure to use a OneConnect profile if you're not specifying a pool for all cases. Else, you could save the name of the VIP's default pool and specify it as a default:when CLIENT_ACCEPTED { Save the name of the VIP's default pool set default_pool [LB::server pool] } when HTTP_REQUEST [ if { [HTTP::uri] starts_with "/products" } { switch [string tolower [HTTP::host]] { "www.domain1.com" { pool Altruik-Furniture; return } "www.domain2.com" { pool Altruik-CarpetOne; return } } } If we're still in the rule, there wasn't a match so explicitly use the default pool pool $default_pool }
- Fotios_30046
Nimbostratus
Aaron,
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