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

Nuruddin_Ahmed_'s avatar
Nuruddin_Ahmed_
Icon for Cirrostratus rankCirrostratus
Jun 14, 2016

irule to allow specific url

Hi,

 

I am trying to allow only specific path of an URI and got this code from devcentral but its giving lot of errors

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet" - "/KURservlet-stage/servlet/KURServlet" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } } }

 

Can someone help me in allowing only specific paths using URI.

 

6 Replies

  • i get below errors 01070151:3: Rule [/Common/Specific-URL-erp-qas] error: /Common/Specific-URL-erp-qas:1: error: [parse error: missing close-brace: possible unbalanced brace in comment][{ switch -glob [string tolower [HTTP::path]] { switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet*" - "/KURservlet-stage/servlet/KURServlet*" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } } }] /Common/Specific-URL-erp-qas:3: error: [command is not valid in the current scope][switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet*" - "/KURservlet-stage/servlet/KURServlet*" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } }] /Common/Specific-URL-erp-qas:3: error: [command is not valid in the current scope][HTTP::path] /Common/Specific-URL-erp-qas:9: error: [command is not valid in the current scope]
  • Hi,

    Find below a working irule :

    when HTTP_REQUEST { 
            switch -glob [HTTP::path] { 
                "/KURservlet/servlet/KURServlet" - 
                "/KURservlet-stage/servlet/KURServlet" - 
                "/KURservlet-test/servlet/KURServlet*" {} 
                default { 
                    HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html 
                } 
            } 
        }
    }
    
    • Nuruddin_Ahmed_'s avatar
      Nuruddin_Ahmed_
      Icon for Cirrostratus rankCirrostratus
      Hi Yann, Thanks for quick and as always the right reply :) i want to achieve one more thing here...lower the path string but i am getting the error in compling the rule when i try that.
  • Hi,

    Find below a working irule :

    when HTTP_REQUEST { 
            switch -glob [HTTP::path] { 
                "/KURservlet/servlet/KURServlet" - 
                "/KURservlet-stage/servlet/KURServlet" - 
                "/KURservlet-test/servlet/KURServlet*" {} 
                default { 
                    HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html 
                } 
            } 
        }
    }
    
    • Nuruddin_Ahmed_'s avatar
      Nuruddin_Ahmed_
      Icon for Cirrostratus rankCirrostratus
      Hi Yann, Thanks for quick and as always the right reply :) i want to achieve one more thing here...lower the path string but i am getting the error in compling the rule when i try that.
  • Hi,

     

    Find below the code to have lower case. Notice that you need to set every path to lower case under the switch condition :

     

    when HTTP_REQUEST { 
            switch -glob [string tolower [HTTP::path]] { 
                "/kurservlet/servlet/kurservlet" - 
                "/kurservlet-stage/servlet/kurservlet" - 
                "/kurservlet-test/servlet/kurservlet*" {} 
                default { 
                    HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html 
                } 
            } 
        }
    }