Forum Discussion

F5_LB_Eng's avatar
F5_LB_Eng
Icon for Cirrostratus rankCirrostratus
Dec 14, 2011

Need Help on merging the 2 Irule

i want to merge the below 2 irule into one irule.

 

 

can any one help me on this.

 

 

 

 

 

rule abc_prod_api '{

 

when CLIENT_ACCEPTED { if { [[ IP::client_addr] equals 63.95.36.13] } { pool prod_res_comm_ssl_196 } elseif { [[ IP::client_addr] equals 216.195.77.144] } { pool prod_res_comm_ssl_199 } } }'

 

 

 

 

 

rule abc_prod_api {

 

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::uri]] {

 

"/mers/api*" {

 

persist none

 

pool prod_res_comm_ssl_api

 

}

 

default {

 

persist source_addr

 

pool prod_res_comm_ssl

 

}

 

}

 

}

 

}

 

 

 

 

 

 

 

 

  • Hi prasanna,

    You are going to need to get them all into the same event so that you can escape some of the routing that is being performed with return statements.

    If you simply merge them the default actions inside of the second iRules switch statement would override the IP Address matching in the first iRules CLIENT_ACCEPTED Event.

    
    when HTTP_REQUEST {
    if { [IP::addr [IP::client_addr] equals 63.95.36.13 ] } {
    pool prod_res_comm_ssl_196
    return
    }
    if { [IP::addr [IP::client_addr] equals 216.195.77.144 ] } {
    pool prod_res_comm_ssl_199
    return
    }
    switch -glob [string tolower [HTTP::uri]] {
    "/mers/api*" {
    persist none
    pool prod_res_comm_ssl_api
    }
    default {
    persist source_addr
    pool prod_res_comm_ssl
    }
    }
    }
    

    Hope this helps.