Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

iRule Path Routing to pool review.

viziony
Altostratus
Altostratus

Hello I have a few designated paths in which I would like to direct to a specific pool otherwise to a default pool. Here is the script that I have came up with using a combination of others I have found on the site. Can you help me confirm this is correct and will work? This is also for HTTPS, so do I need to change "when HTTP_REQUEST" to "when HTTPS_REQUEST"? 

 

 

 

when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] equals "/a.php" or [string tolower [HTTP::uri]] starts_with "/b.php"} or [string tolower [HTTP::uri]] starts_with "/c/*"} { pool /Common/pool-A_pool } else { pool Common/pool-B_apool }

}

 

 

 

Thanks for your time.

3 REPLIES 3

Daniel_Wolf
Nacreous
Nacreous

Hi @viziony

I think you could use a switch statement rather than a lot of or conditions. This iRule should work for you.
Instead of starts_with, I use a wildcard *.  You could also use HTTP::path instead of HTTP::uri.

when HTTP_REQUEST {
    switch -glob -- [string tolower [HTTP::uri]] {
        "/a.php*" -
        "/b.php*" -
        "/c.php*" {
            pool my_pool_ABC
        }
        default {
            pool my_pool_XYZ
        }
    }
}

Let me know if this one works for you, or it needs adjustments.

KR
Daniel

Thank you Dan for the quick reply! Will update this thread once I test it out.

vaibhav
Nimbostratus
Nimbostratus

Yep switch -glob is best option for you and for more details on the various options/functions available to switch pool you can refer below documentation it is a good read

https://community.f5.com/t5/technical-articles/irules-101-05-selecting-pools-pool-members-and-nodes/...