Forum Discussion

AngryCat_52750's avatar
AngryCat_52750
Icon for Nimbostratus rankNimbostratus
Nov 30, 2012

Check URI and then drop

We are looking to setup an irule that would only permit a specfic URI and drop any other requests..

 

How do i script the part to do the "dropping"?

 

when HTTP_REQUEST {

 

if { [HTTP::uri] starts_with "/abc" } {

 

pool abc_servers

 

else

 

???

 

}

 

}

 

4 Replies

  • The simplest approach might be something like this:

    
    when HTTP_REQUEST {
        if { not ( [string tolower [HTTP::uri]] starts_with "/abc" ) } {
            drop
        }
    }
    

    You probably already have the pool defined in the virtual server, so you don't need to assign it here. The 'drop' command is also a bit harsh. You can instead either redirect the user (HTTP::respond 302 Location "blah"), or sending them some friendly HTML (HTTP::respond 200 content "go away!").

  • Brian_Deitch_11's avatar
    Brian_Deitch_11
    Historic F5 Account
    Personally I believe a switch would scale better and would be easier on the eyes

    
    ltm rule ir_bdizzle {
        when HTTP_REQUEST {
            switch -glob  [string tolower [HTTP::uri]] {
                */enter/url/here* { pool pool_a_80 }
                */abc* { pool pool_abc_80 }
                default { drop }
            }
        }
    }