Forum Discussion

pkhatri_72515's avatar
pkhatri_72515
Icon for Nimbostratus rankNimbostratus
Mar 31, 2010

Need help with iRule

Dear Experts,

 

I need help with iRule:

 

 

currently i have following iRule: (which is working fine)

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

when HTTP_REQUEST {

 

if { ([string tolower [HTTP::uri]] starts_with "/classkb/") or ([string tolower [HTTP::uri]] equals "/classkb") } {

 

if { not ([matchclass [IP::client_addr] equals $::Classkb_allowed_IPs]) } {

 

log local0. "Caught [HTTP::uri] from [IP::client_addr]"

 

HTTP::redirect "http://static.blabla.com/403.htm"

 

}

 

}

 

}

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

now we need "/classkb/assests" url to be publically accessed, how would i modify this iRule? Need help with adding another if statement.

 

Thanks,

 

PK.

5 Replies

  • How about something along the lines of this.

      
      when HTTP_REQUEST {   
       set path [string tolower [HTTP::path]]   
           log local0. $path   
       switch -glob $path {   
       "/classkb/assets"{   
       }   
       "/classkb*"{   
       if { not ([matchclass [IP::client_addr] equals $::Classkb_allowed_IPs]) } {   
       log local0. "Caught [HTTP::uri] from [IP::client_addr]"   
       HTTP::redirect "http://static.blabla.com/403.htm"   
       }   
       }   
       }   
       }  
      

    Caveat: I've not tested it, and might not be %100 correct syntax
  • That worked!! Thanks,

     

    I had to add '*' at the end of '/classkb/assets".

     

     

    Thanks again for your help.

     

    PK.

     

  • well, guess I was wrong, users are reporting that they are able to now access

     

    http://bla.bla.com/classkb - which should be accessed only by those permitted IPs while

     

    http://bla.bla.com/classkb/assets should be accessed by everyone.

     

     

     

    PK.