Forum Discussion

Jim_Raleigh's avatar
Jim_Raleigh
Icon for Nimbostratus rankNimbostratus
Feb 01, 2018

Converting iRule from v9 to v12

In the process of migrating from v9.4.7 to v12.1.1 and am having issues with iRules... In the following I am pulling string Data Groups for B2B_Blocked_URLS and B2B_URLS... Could you assist on how I would do this on the new version?

when RULE_INIT {
    set ::DEFAULT_URI "/b2b/init.do"
}
when HTTP_REQUEST {
    if { [matchclass [HTTP::uri] contains $::B2B_Blocked_URLS] } {
        HTTP::redirect "$::DEFAULT_URI" 
    } 
    if { [matchclass [HTTP::uri] contains $::B2B_URLS] } { 
    } else { 
        log local0.crit [HTTP::uri] HTTP::redirect "$::DEFAULT_URI"
    }
}

 

1 Reply

  • Hi Jim,

    You can try the following, please be advised you can now achieve the same results using a Traffic Policy (configured in the GUI). Code that is no longer supported are variables declared in the global namespace ($::var) these will demote your CMP so the iRule will only run on one CPU. Also matchclass has been deprecated

     

    when RULE_INIT {
        set static::DEFAULT_URI "/b2b/init.do"
    }
    
    when HTTP_REQUEST {
    
        if {[class match [HTTP::uri] contains B2B_Blocked_URLS] } {
            HTTP::redirect $static::DEFAULT_URI 
        } elseif { not ([class match [HTTP::uri] contains B2B_URLS]) } {
            log local0.crit [HTTP::uri]
            HTTP::redirect $static::DEFAULT_URI
        }
    }