Forum Discussion

Thiyagu_343098's avatar
Thiyagu_343098
Icon for Nimbostratus rankNimbostratus
Jan 21, 2018

Assigning multiple iRULES to a VIP

Hello All, I need your suggestion on assigning multiple iRULES to the same VIP. What would be the best approach to be followed while assigning multiple iRULES to the same VIP? - Does the traffic to the VIP will be processed in sequential order? for instance the first irule in the list process the traffic first and then the second irule in the list of irules assigned to the VIP and then the third iRULE in the list?

 

  • Does LTM support Nested irule for example calling an another irule from the irule? Regards, T.K

5 Replies

  • If you do not use Priority command, then all iRules are silently allocated priority of 500. All equal. Then the order in which they are mapped to Virtual Server will have significance, as you already guessed. But this is bad practice with no benefits. Occasional bugs due to config reload can mess up the order those rules are mapped to your Virtual Servers.

    Note that only the current event that is taking place will be affected by

    priority
    command.

    A snapshot of how multiple iRules are actually processed will look as follows

    RULE_INIT event of iRule that has priority (or event priority) set to 1
    ...
    RULE_INIT event of iRule that has priority set to 999
    ...
    HTTP_REQUEST event of iRule that has priority set to 1
    ...
    HTTP_REQUEST event of iRule that has priority set to 999
    ...
    

    Does LTM support Nested irule for example calling an another irule from the irule?

    • With standard TCL iRules, nope. Maybe you can do it with iRulesLX but cannot confirm.

    Regards,

  • Thanks a lot Hannes for your reply. If suppose there are two iRULES first one for inserting the client IP and second one for content switching based on URI?

     

    Could you please help me to know in which order I have add the iRULES?

     

    Regards, Thiyagu

     

  • Why do you need 2 irule for the above scenario, both take place in http request event, can't you achieve both in a single Irule. Or am i missing something here. Can you post both your Irules.

     

  • Hi Jai, Here is the irules: First, when HTTP_REQUEST { set rd "%[ROUTE::domain]" set client_ip [string map "$rd \"\"" [IP::client_addr]] HTTP::header insert srcaddr $client_ip }

     

    Second, when HTTP_REQUEST { if {[HTTP::uri] starts_with "/uri1" } { pool pool1 } elseif {[HTTP::uri] starts_with "/uri2" } { pool pool2 } elseif {[HTTP::uri] starts_with "/uri3" } { pool pool3 } }

     

    Would I able to merge both the irules without the flow of the application to the application servers based on the URI?

     

    Regards, Thiyagu

     

  • yes that should work,

    when HTTP_REQUEST {
    set rd "%[ROUTE::domain]"
    set client_ip [string map "$rd \"\"" [IP::client_addr]]
    HTTP::header insert srcaddr $client_ip
    if {[HTTP::uri] starts_with "/uri1" } {
        pool pool1
      } elseif {[HTTP::uri] starts_with "/uri2" } {
        pool pool2
      } elseif {[HTTP::uri] starts_with "/uri3" } {
        pool pool3
      } else {
       pool default      
    }
    }