For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Techgeeeg_28888's avatar
Techgeeeg_28888
Icon for Nimbostratus rankNimbostratus
Aug 19, 2015

Irule help needed

Hi Guys,

 

I have a requirement of an irule to achieve the following, will someone kindly help me out.

 

I have a URL http"//www.service.com/_badlink/*.pdf" i want to block this and throw a page not avaliable message will someone provide quick help here.

 

Regards,

 

4 Replies

  • when HTTP_REQUEST {
     if {[HTTP::host] eq "[www.service.com](http://www.service.com)" and [HTTP::uri] starts_with "/_badlink/"} {
        switch -glob [string tolower [HTTP::uri]] {
            "*.pdf" {
                set message "illegal file download !!!"
                HTTP::respond 200 content [subst -nocommands -nobackslashes [ifile get message.html]] noserver "Content-Type" "text/html"
            }
        }
     }
    }
    

    Then, you have to add an ifile containing the html content of your message. You can set $message in your content and it will be replaced by the value of the variable in irule.

  • Thanks Yann can you tell me more about ifile pls also I didn't see the "_badlink" in the irule as I need to block it only for that folder.

     

  • Hello, please find below the irule reposted. The badlink is trapped here :

    when HTTP_REQUEST {
     if {[HTTP::host] eq "www.service.com" and [HTTP::uri] starts_with "/_badlink/" } {
        switch -glob [string tolower [HTTP::uri]] {
            "*.pdf" {
                set message "illegal file download !!!"
                HTTP::respond 200 content [subst -nocommands -nobackslashes [ifile get message.html]] noserver "Content-Type" "text/html"
            }
        }
     }
    }
    

    You can create an ifile by importing your html content in System > File Management > Import ifile

    Then you create an ifile object that refer to the ifile content previously imported in Local Traffic > iRules > iFile List. In the irule you refer to the ifile object created in iRules > iFile List tab

    For the html content itself, it's up to you to create an html message with your own look&feel. The bonus is that you just have to set $message in the html file where you want the irule to replace this variable by the value.