Forum Discussion

TWSS_18275's avatar
TWSS_18275
Icon for Nimbostratus rankNimbostratus
Feb 21, 2008

Nested iRules

Is it possible to call an iRule from within an iRule?

 

 

For example:

 

 

rule rule_serv_id_https

 

when HTTP_RESPONSE {

 

set serv_ip [getfield [IP::server_addr] "." 3]

 

append serv_ip "." [getfield [IP::server_addr] "." 4]

 

HTTP::header insert Server_Id $serv_ip

 

}

 

}

 

 

rule rule_bot_https {

 

when HTTP_REQUEST {

 

if { [matchclass [string tolower [HTTP::header User-Agent]] contains $::bots] } {

 

HTTP::header insert Is_Bot "Yes"

 

persist none

 

pool pool_bot_1_https

 

}

 

}

 

 

rule rule_serv_id_https

 

}

 

  • Hi,

     

     

    You can't call one rule from another. You could combine the rules into a single rule. Or you could add the two rules to the virtual server and they will be triggered according to the priority (or if no priority is specified, then the order they're listed for the VIP). For details on priority, check the wiki page: (Click here).

     

     

    As your rules look to be completely unrelated, you could keep the code in separate rules and add them to the VIP together. Priority in this case wouldn't matter as nothing in either rule would conflict with the other.

     

     

    Aaron
  • or probably you can try, in the first iRule, using "virtual " command to call secend vip (instead of using "pool command") and then associates new rule to the second vip (then use pool command here). but you may need to upgrade BIG-IP to newer version. (9.4.2 should support this as I remember)