Forum Discussion

MW1's avatar
MW1
Icon for Cirrus rankCirrus
Jan 08, 2009

irule newbie - pointer please!

Hi all,

 

I'm very new to the irules and have alot to learn so apologies for asking something that I presume is very simple.

 

 

I need to restrict access to three URI's these are:

 

 

https://servername/admin/*

 

https://servername/user/*

 

https://servername/home/*

 

 

And block all other access (ie https://servername/admin/home allowed but not say https://servername/game)

 

 

I believe I will need to turn the request in to lowercase to avoid having to match the various cases ie https://servername/ADMIN/*. I've seen lots of post on matching a URI which contains a string but unsure on how to specify if it does not contain a string.

 

 

Can anyone point me in the right direction?

 

 

Thanks in advance

 

Matt

2 Replies

  • James_Quinby_46's avatar
    James_Quinby_46
    Historic F5 Account
    Matt -

    This will do the trick:

        
        when HTTP_REQUEST {    
            
        switch -glob [string tolower [HTTP::uri]] {    
        "/user/*" -    
        "/home/*" -    
        "/admin/*" {    
        pool apache    
        }    
            
        default {    
        discard    
        }    
            
              }    
               
        }    
        

    You'll want to change the name of the pool up there from 'apache' to whatever is appropriate. The two key bits in here are the 'switch' and 'string tolower'.

    There's more info on switch here:

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=244

    ...and on Tcl's string manipulation options here:

    http://www.tcl.tk/man/tcl8.5/TclCmd/string.htmM49

    One consideration might be the display of a 'sorry' page of some kind rather than just discarding the request silently.

    (updated - tightened up the matching a little)
  • Works well. Thanks for the links - time for me to do some reading!

     

     

    thanks again

     

     

    Matt