Forum Discussion

falooda_281506's avatar
falooda_281506
Icon for Nimbostratus rankNimbostratus
Sep 14, 2016

iRule to route

I want to create an irule for the below. Is it appropriate to have specific URI's define going to the URI Pool or can we say anything with a URI goes to this pool. Everything else root of example.com goes to another pool

 

example.com goes to pool Example

 

and anything else example.com with any URI goes to pool URI_POOL

 

would this be appropriate:

 

when HTTP REQUEST { if {[string tolower [HTTP::uri]] contains "/*/}{ pool URI_POOL} else pool EXAMPLE }

 

2 Replies

  • when HTTP_REQUEST {
    if { [HTTP::host] eq "example.com" } {
     if { [HTTP::uri] eq "/" } {
     pool POOL-EXAMPLE
     } else {
     pool POOL_URI-POOL
     }
    }
    }
    
  • Hi Falooda,

    you may try one of the snippets below...

    Using a

    [string match]
    syntax:

    when HTTP REQUEST { 
        if { [string match "/*/*" [HTTP::path]] } then { 
            pool URI_POOL
        } else {
            pool EXAMPLE 
        }
    }
    

    Using a

    [switch -glob]
    syntax:

    when HTTP REQUEST { 
        switch -glob -- [HTTP::path] "/*/*" { 
            pool URI_POOL
        } default {
            pool EXAMPLE 
        }
    }
    

    Note: The first example has a slightly better performance.

    Cheers, Kai