Forum Discussion
Maxim_Taskov_90
Nimbostratus
Jun 26, 2008Match URI Path and Choose Pool Plus Pool Availability Check
Hi ...
I am trying to create a rule with the following logic and assign it on a single virtual server:
1. If URI path matches string class MyURI (listing about fifteen URI paths) AND the active members of Pool2 are more than zero, choose Pool2.
2. If URI path does not match string class MyURI OR Pool2 has zero active members, choose Pool1.
I came up with the following ... please tell me if the logic will be processed correctly, that will satisfy the above two requirements and if this is the most efficient way to accomplish my objective:
when HTTP_REQUEST {
if { [matchclass [HTTP::uri] starts_with $::MyURI] } {
if { [active_members Pool2] > 0 } {
pool Pool2
} else {
pool Pool1
}
}
}
Thanks!
- Colin_Walker_12Historic F5 AccountThat logic looks correct to me. You could compress the two checks into one if statement combined with an and, but it's logically the same thing, just a tiny bit less code.
- Maxim_Taskov_90
Nimbostratus
Thanks Colin. I knew about the option of single AND rather than multiple IF statements but I never had a good luck with the AND option. The last iRule I wrote did not work at all with the AND statement. It started working as soon as I switched to a multiple IF statement. - hoolio
Cirrostratus
Do you have a default pool on the VIP? Using the rule you posted above, you're not explicitly specifying a pool for requests which don't match the first condition.when HTTP_REQUEST { if { [matchclass [HTTP::uri] starts_with $::MyURI] } { if { [active_members Pool2] > 0 } { pool Pool2 } else { pool Pool1 } } else { pool Pool1 } }
when HTTP_REQUEST { if { [matchclass [HTTP::uri] starts_with $::MyURI] and [active_members Pool2] > 0} { pool Pool2 } else { pool Pool1 } }
- Maxim_Taskov_90
Nimbostratus
Thanks for the reply Aaron. Yes, I forgot to mention this but I do have a default pool configured at the VIP for requests that do not fit the iRule conditions. - hoolio
Cirrostratus
If I assign a pool in any scenario in an iRule, I normally assign it for all. In general, it makes it easier to follow the logic of the iRule. - Maxim_Taskov_90
Nimbostratus
Thanks for the advice Aaron. I will follow it.
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