Forum Discussion

Robert_47833's avatar
Robert_47833
Icon for Altostratus rankAltostratus
Jun 15, 2012

3 irules order

hello,dear irule

 

 

I met an headache stuff recently

 

 

 

 

there is one VIP which has irule 1 ,irule 2 and irule 3 assigned to it

 

 

 

1:I 'd like to use some syntax in irule 1 ,if request match some pattern,it will continue to go through irule 1 ,but don't execute irule 2 and irule 3

 

 

2:if request doesn't match some pattern ,it will go to irule 2 and irule 3

 

 

 

thanks in advance

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • Hi Robbie,

     

     

    You could set a local variable in Rule1 which Rule2 and Rule3 check before executing their code. Or you could combine the iRules into one if that makes sense for the logic. Here's a simple example:

     

     

    
    rule rule1 {
    when CLIENT_ACCEPTED {
    if {$some_check==1}{
    set run_other_rules 1
    } else {
    set run_other_rules 0
    }
    }
    }
    
    rule rule2 {
    when CLIENT_ACCEPTED {
    if {$run_other_rules==1}{
     Exit this event in this rule
    return
    }
    }
    when HTTP_REQUEST {
    if {$run_other_rules==1}{
     Exit this event in this rule
    return
    }
    }
    }
    
    rule rule3 {
    when CLIENT_ACCEPTED {
    if {$run_other_rules==1}{
     Exit this event in this rule
    return
    }
    }
    }
    

     

     

    Aaron
  • thanks,Aaron

     

    this idea is pretty good

     

    I 'd like to do some change on it

     

    because rule 2 and rule 3 were there,I only need to add rule 1 to achieve this,but I don't wanna change any stuff on rule 2 and rule 3

     

    maybe I can use this variable "run_other_rules" to handle the different events in the rule 1 while I can use "event" command to handle same event in the rule 2 and rule 3,right?

     

     

    thanks in advance

     

  • hello,Aaron

     

    I know event disable in a HTTP::request will disable all HTTP::request event in all irule in the same VIP

     

     

    in some place,I found this: they enable the HTTP::request in HTTP_response

     

    rule enable_HTTP_REQUEST_on_response {

     

    when HTTP_RESPONSE {

     

    event enable HTTP_REQUEST

     

    }

     

    }

     

     

    I don't understand this,would u give me an example to explain this?

     

    in one connection,request 1 hit the rule 1 and disabled......and so on

     

     

    thanks in advance