Forum Discussion

eliton_199802's avatar
eliton_199802
Icon for Nimbostratus rankNimbostratus
May 24, 2017

Directory blocking iRule with exceptions

I'm looking to implement that does the following

 

If users attempt to access

 

/directory1 /directory2 /directory3

 

They are blocked/logged, however they are allowed a specific file under the directory, such as

 

/directory1/file1 /directory2/file27

 

Everything else in those directories besides the files specifies above are blocked/logged

 

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    Try this one:

    when HTTP_REQUEST {
        switch -glob -- [string tolower [HTTP::path]] {
            "/directory1/file1" {
            }
            /"directory1*" {
                log local0. "[IP::client_addr] trying [HTTP::path]: blocked."
                reject
            }
            /"directory2/file27" {
            }
            "/directory2*" {
                log local0. "[IP::client_addr] trying [HTTP::path]: blocked."
                reject
            }
            default {
            }
        }
    }
    

    .