Forum Discussion

Ron_130795's avatar
Ron_130795
Icon for Nimbostratus rankNimbostratus
Jul 15, 2014

Irule help with creating a single VIP but with multiple pools

I have a website called 'bigip.com', however, I also have a website call 'bigip.com/blog' and 'bigip.com/application' using the same VIP. Each url needs to point to a different pools. How can I write an iRule where bigip.com point to a pool called 'bigip' on port 1000 and bigip.com/blog points to a pool called 'bigip2' on port 2000 and bigip.com/application points to a pool called 'bigip3' ??

 

Thanks for any help

 

3 Replies

  • Here is a tutorial: iRules 101 - Selecting pools, nodes

    This should work for you. Your port number is controlled in the pool itself so there is no need to specify that in any way. Also depending on the use case you may want to use "contains" or "starts_with" instead of "eq" in the second and third condition of this iRule.

    when HTTP_REQUEST { 
     if { [HTTP::uri] eq "/" } { 
        pool bigip 
     } elseif { [string tolower [HTTP::uri]] eq "/blog" } { 
        pool bigip2
     } elseif { [string tolower [HTTP::uri]] eq "/application" } {
        pool bigip3
     }
     If no pool is configured in the virtual as a default/fallback
    default { pool bigip }
    }
    
  • This is how I do what your are looking to do. I updated /blog_ to /blog* and /application_ to /application*.

    when HTTP_REQUEST {
       Check requested uri header (set to lowercase)
    switch -glob [string tolower [HTTP::uri]] {
        "/blog*" {
            pool bigip2
        }
        "/application*" {
            pool bigip3
        }
        default {
            pool bigip
        }
    }
    }