Forum Discussion

Tim_Abbott_4960's avatar
Tim_Abbott_4960
Icon for Nimbostratus rankNimbostratus
Jun 08, 2005

New to iRules: Need persistance based on virutal directory

I am new to the iRules and I'm looking for a way to persist a virtual directory.

 

 

Here is my issue.

 

 

I have one website www.mysite.com but I have two applications on that website; www.mysite.com/app1 and www.mysite.com/app2. The app1 works fine with the load balancer. The app2 needs to have users persisted to the same web server during that session.

 

 

How do I configure an iRule to look for the uri of "app2" and turn persistence on? And what are the recommendations and the type of persistence I should use in this scenario (Simple, Cookie - Insert, rewrite, Passive, Hash -, Universal, etc..)

 

 

Thanks,

 

 

Tim

 

  • OK, here is what I've come up with so far but I need some more help.

     
      rule sautooffice_uri {  
           when HTTP_REQUEST {  
              if { [HTTP::uri] starts_with "/sautooffice" } {  
         persist cookie insert cdmao  
         pool www.cdmdata.com  
              }  
           }  
        
      virtual CDMDataProduction {  
         destination 10.250.110.100:http  
         ip protocol tcp  
         profile http tcp  
         pool www.cdmdata.com  
          persist AppCookie  
         rule sautooffice_uri  
      } 
     

    If I am reading this correctly it will persist all of the connections going to the pool CDMDataProduction. I need to only persist those that have the uri /sauotooffice. How do I NOT persist any other sessions that do NOT use /sautooffice?

    Thanks,

    Tim
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Actually, you are very close. Since you already have persistence enabled on the virtual, all you need to do in the rule is disable persistence for the urls you don't want it on. Try changing your rule like this:

     
     rule sautooffice_uri {  
        when HTTP_REQUEST {  
           if { not ( [HTTP::uri] starts_with "/sautooffice" ) } {  
              persist none  
           }  
        } 
     } 
     

  • Sure is, If you want to cover all cases, you can use the TCL builtin "string tolower" command to put the uri in lower case before you compare

    if { not ( [string tolower [HTTP::uri]] starts_with "/sautooffice" ) } {

    This will force what's in the uri to lowercase and then compare it to your matched lowercase string.

    -Joe