For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

viziony's avatar
viziony
Icon for Cirrus rankCirrus
Feb 03, 2022

iRule Path Routing to pool review.

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

  • 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

    • viziony's avatar
      viziony
      Icon for Cirrus rankCirrus

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