Forum Discussion

MikeStearns_600's avatar
MikeStearns_600
Icon for Nimbostratus rankNimbostratus
Jan 29, 2009

HELP with a new irule...disable acceleration

Hello. I am looking to create an irule to do the following:

 

 

If the request doesn't end with /abc123.html

 

AND

 

if the request doesn't begin with /CPOS2

 

AND

 

if the request doesn't begin with /NEXTAPP

 

THEN

 

disable acceleration

 

AND

 

disable LTM cache

 

 

 

This is what I have so far. I would appreciate any help. I am new to writing code.

 

 

when HTTP_REQUEST {

 

if { not ( [HTTP::uri] ends_with "/abc123.html" && not ( [HTTP::uri] begins_with "/CPOS2" && not ( [HTTP::uri] begins_with "/NEXTAPP") } {

 

HTTP::class disable

 

CACHE::disable

 

}

7 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    When you say "disable acceleration" what exactly are you looking to do?

     

     

    Regardless, your code is close but you were missing a few closing parens. This should work a little better if disabling the class and the cache is really what you want to do.

     

     

     
     when HTTP_REQUEST { 
       if { (not ( [HTTP::uri] ends_with "/abc123.html")) && ( not ( [HTTP::uri] begins_with "/CPOS2")) && (not ( [HTTP::uri] begins_with "/NEXTAPP")) } { 
         HTTP::class disable 
         CACHE::disable 
       } 
     } 
     

     

     

    Colin
  • We want to disable the IBR feature while adding new applications to the F5. I guess we prefer doing an iRule instead of a WA policy change. For example.....we would be able to setup the policy prior to production and the only change for us to do would be deleting the iRule for the new application to go productive.

     

     

    I really appreciate the help.
  • I seem to be getting the following error when trying to create the irule above.

     

     

     

    01070151:3: Rule [nextapp_going_live] error:

     

    line 2: [parse error: PARSE syntax 98 {syntax error in expression " (not ( [HTTP::uri] ends_with "/abc123.html")) && ( not ( [H...": looking for close parenthesis}] [{ (not ( [HTTP::uri] ends_with "/abc123.html")) && ( not ( [HTTP::uri] begins_with "/CPOS2")) && (not ( [HTTP::uri] begins_with "/NEXTAPP")) }]

     

     

     

     

    Here is the irule again.

     

     

    when HTTP_REQUEST {

     

    if { (not ( [HTTP::uri] ends_with "/abc123.html")) && ( not ( [HTTP::uri] begins_with "/CPOS2")) && (not ( [HTTP::uri] begins_with "/NEXTAPP")) } {

     

    HTTP::class disable

     

    CACHE::disable

     

    }

     

    }
  • The operator should be starts_with instead of begins_with
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Also, I think 'HTTP::class disable' disables the class selection for the duration of the TCP connection. You may want to enable it if the checks aren't true. I think CACHE::disable isn't subject to this as the caching decision is done on each request/response. You could check this by making one matching request and one non-matching request over the same TCP connection and check the debug logging.

    Also the AND'd NOTs are a little difficult to follow. Maybe something like this would be easier?

     
     when HTTP_REQUEST { 
      
         Check if URI matches these checks 
        switch -glob [HTTP::uri] { 
      
           "*/abc123.html" - 
           "/CPOS2*" -  
           "/NEXTAPP*" { 
              log local0. "[IP::client_addr]:[TCP::client_port]: Not disabling caching/enabling class selection for [HTTP::uri]" 
              HTTP::class enable 
           } 
           default { 
              log local0. "[IP::client_addr]:[TCP::client_port]: Disabling caching/class selection for [HTTP::uri]" 
              HTTP::class disable 
              CACHE::disable 
           } 
        } 
     } 
     

    Aaron
  • Thanks Aaron. If this does what i need, which section do I take out to stop the debug logging? I hope to test later this week.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    To disable the logging, you can comment out the log lines with a hash:

     

     

    log local0. "..."

     

     

    or remove them altogether.

     

     

    Aaron