Forum Discussion

wick54's avatar
wick54
Icon for Nimbostratus rankNimbostratus
Sep 16, 2019

Write an irule or a policy to allow specific URIs

Hi Guys,

 

I'm quite new to F5. We have a requirement for allow only 4 specific URIs and block any other URI. What would be the best way to do it. Would it be using an irule or using a LTM policy? Are you able to provide an example irule or LTM policy for this please?

6 Replies

  • use this iRule:

    when HTTP_REQUEST {
    	switch -glob [string tolower [HTTP::uri]]
    		"/uri1*" -
    		"/uri2*" -
    		"/uri3*" -
    		"/uri4" 
    		{
    			#do nothing
    		}
    		default
    		{
    			#drop others
    			drop
    		}
    }
    • wick54's avatar
      wick54
      Icon for Nimbostratus rankNimbostratus

      Thanks, I will try this, if URI contains Uppercase characters, do i need to change to it lower case in iRule? would that be matched?

  • Hi,

     

    I think usign an irule for your need will give you a lot more flexibility you can answer a blocking page to the user, a drop, a reset ...

     

    Anyway find an example with ltm policy (with reset)... if you want more flexibility (blocage page in ifile for example use an irule):

     

    regards

     

     

    • wick54's avatar
      wick54
      Icon for Nimbostratus rankNimbostratus

      If URI contains Uppercase characters, do i need to change to it lower case in LTM policy? would that be matched?

  • It would be match. By default it's not case sensitive.

    If you want to enable "case sensitive" you can do IT in options menu (in ltm policy in right)...