Forum Discussion

Brad_146558's avatar
Brad_146558
Icon for Nimbostratus rankNimbostratus
Mar 26, 2015
Solved

iRule Question

Hi everyone, this is my first time using Data Group lists and I'm having some trouble with the below iRule. Does anyone have any suggestions on what I might be doing wrong?

 

Also a summary as to what the iRule is doing. Basically if you are trying to go a URI other than one on the "approved" data group list, you get redirected back to the root level of the site.

 

when HTTP_REQUEST {

 

if { [[HTTP::uri] starts_with a_string] } {

 

pool some_pool

 

}

 

else { HTTP::redirect "https://somedomain.com/" }

 

}

 

  • This should do the trick. Just make sure your DG is a string list and your /URIs go in the string field.

    when HTTP_REQUEST {
        if { [class match [HTTP::uri] starts_with "/Common/"] } {
            pool some_pool
        }
        else {
            HTTP::redirect "https://somedomain.com/"
        }
    }
    

10 Replies

  • This should do the trick. Just make sure your DG is a string list and your /URIs go in the string field.

    when HTTP_REQUEST {
        if { [class match [HTTP::uri] starts_with "/Common/"] } {
            pool some_pool
        }
        else {
            HTTP::redirect "https://somedomain.com/"
        }
    }
    
    • Brad_Parker_139's avatar
      Brad_Parker_139
      Icon for Nacreous rankNacreous
      probably want to [string tolower [HTTP::uri]] to make sure your matching is all lower case.
    • Brad_146558's avatar
      Brad_146558
      Icon for Nimbostratus rankNimbostratus
      Unfortunately it still seems like it isn't matching against the datagroup and forwarding all URIs on to the pool.
  • This should do the trick. Just make sure your DG is a string list and your /URIs go in the string field.

    when HTTP_REQUEST {
        if { [class match [HTTP::uri] starts_with "/Common/"] } {
            pool some_pool
        }
        else {
            HTTP::redirect "https://somedomain.com/"
        }
    }
    
    • Brad_Parker's avatar
      Brad_Parker
      Icon for Cirrus rankCirrus
      probably want to [string tolower [HTTP::uri]] to make sure your matching is all lower case.
    • Brad_146558's avatar
      Brad_146558
      Icon for Nimbostratus rankNimbostratus
      Unfortunately it still seems like it isn't matching against the datagroup and forwarding all URIs on to the pool.
  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Brad - looks like the iRule above has too many } but it would error when creating the irule so can i assume you've removed one of these.

    Anyway, what does your DG look like. I tested the irule above with the following DG and it worked just as Brad Parker suggested.

    Here's my DG

    ltm data-group internal uri_allowed {
        records {
            /test { }
        }
        type string