Forum Discussion

BaltoStar_12467's avatar
Oct 01, 2013

possible to have multi-layered irules ?

I need to make changes to an existing prod instance of F5 BIG-IP LTM VE 10.2.4.

 

It has a virtual server configured with a single iRule that contains 2 simple switch statements that parse host & uri and route to various pools.

 

For switch case ( pool ) , I need to add some redirect/rewrite functionality.

 

I would prefer not to alter the existing Rule - or alter it as little as possible.

 

Is it possible to "layer in" another irule ? So if the first irule gets to the switch case it routes to another irule ?

 

Alternately , is it possible to attach an irule to the destination pool so that it intercepts all traffic routed to that pool ?

 

1 Reply

  • yes, you could do something like that by using variables to do so. I would be careful at the maintainability of such a solution. But basically:

    Rule 1

    priority 100
    when RULE_INIT {
      set static::trigger 0
    }
    when HTTP_REQUEST {
      switch [LB::server pool] {
        "pool1" { set static::trigger 1 }
        "pool2" { set static::trigger 2 }
        "pool3" { set static::trigger 3 }
      }
    }
    

    Pool1 Rule

    priority 110
    when HTTP_REQUEST {
      if { $static::trigger == 1 } {
        do stuff
      }
    }
    

    Edit->actually, LB::server pool probably won't be very accurate in HTTP_REQUEST, so you might need to move some of the logic to a later event. The flow from iRule->iRule mapping stands though.