Forum Discussion

Daniel_Cheng_18's avatar
Daniel_Cheng_18
Icon for Nimbostratus rankNimbostratus
Apr 12, 2007

Can't convert iRule by OTCU

We found the following iRule can't convert When we upgrade our BIGIP from v4.x to v9.x by OTCU.

 

 

if (http_uri matches_regex "/opscommon") {

 

log "*** client_addr: " + client_addr + ", uri: " + http_uri

 

redirect to "http://" + http_host + "/opsfop/" + substr(http_uri, 10, 1000)

 

}

 

else {

 

use pool OPS-PM

 

}

 

}

 

 

 

We are no experience on iRule, Any body can tech me how to convert this iRule to v9 ?

 

 

Many Thx.

 

Daniel
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    I think this should be functionally equivalent:

    
    if { [HTTP::uri] starts_with "/opscommon"}{
       log local0. "client: [IP::client_addr], URI: [HTTP::uri]"
       HTTP::redirect "http://[HTTP::host]/opsfop/[HTTP::uri]"
    }
    else {
       pool OPS-PM
    }

    I replaced the regex you had with a string comparison, as it doesn't look like you need to use a regex to verify the URI doesn't start with /opscommon (and a regex is less efficient than a string comparison). You can use matches_regex if you need to though.

    Aaron
  • How About the "substr(http_uri, 10, 1000)" ??

     

    Do we need to apply this string in V9 and how?

     

     

    Many Thx.

     

    Daniel

     

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Sorry about dropping that. You're trimming off the /opscommon/ from the requested URI using substring. To do that in 9.x you could replace /opscommon with /opsfop/ using 'string map', or use substr.

    Here's an example, using string map:

    
    if { [HTTP::uri] starts_with "/opscommon/"}{
       log local0. "client: [IP::client_addr], original URI: [HTTP::uri], redirect URI: [string map {/opscommon/ /opsfop/} [HTTP::uri]]"
       HTTP::redirect "http://[HTTP::host][string map {/opscommon/ /opsfop/} [HTTP::uri]]"
    }
    else {
       pool OPS-PM
    }

    [edited to fix misplaced }]

    Aaron
  • Thank you for help to convert our iRule to v9 format. Actually , I want to learn more about iRue.

     

    Could you please show me some example to talking about what does this iRule doing for??

     

     

    Base on my clumsy program knowledge, this iRule is search the URI if match "/opscommon" then will take a log with client IP URL ETC......

     

    then where will the traffic redirect to???

     

     

    Thx for help,

     

    Daniel