Forum Discussion

AJN_Network_Tea's avatar
AJN_Network_Tea
Icon for Nimbostratus rankNimbostratus
Dec 26, 2016

irule URI Match and replace function disrupting website format

We have a published webapp xyz.com which has the following irule for URI match and replace functionality for certain internal links. below is a functional irule for the site which works fine.

/*START IRULE/

when HTTP_REQUEST { HTTP::header remove Accept-Encoding STREAM::disable

if { [HTTP::uri] equals "/" } {
    HTTP::header replace "Host" "server1.domain:888" 
    HTTP::uri "/lllxy/"
    pool ABC member 1.2.3.4
}

if { [HTTP::uri] equals "/yyy/" } {
    HTTP::header replace "Host" "server1.domain:888" 
    HTTP::uri "/yyy/"
    pool ABC member 1.2.3.4
}

}

when HTTP_RESPONSE { if { [HTTP::header exists Location] } { HTTP::header replace Location [string map {"server1.domain:888" "xyz.com"} [HTTP::header Location]] } STREAM::disable STREAM::expression "@server1.domain:888@xyz.com@" STREAM::enable }

/*END IRULE/

Whenever we append and add another URI match and replace string for a different node on the same irule, the website looses its formatting. here is what we are adding.

/******Under HTTP_REQUEST *****/

if { [HTTP::uri] equals "/www/" } { HTTP::header replace "Host" "server100.domain:666" HTTP::uri "/www/" pool ABC member 9.9.9.9 }

/******Under HTTP_RESPONSE *****/

    if { [HTTP::header exists Location] } {
    HTTP::header replace Location [string map {"server100.domain:666" "xyz.com"}
     [HTTP::header Location]]
}
 STREAM::disable
 STREAM::expression "@server100.domain:666@xyz.com@"
 STREAM::enable

}

Don’t know if the syntax is correct or are we missing something.

Any guidance in the right direction will be helpful.

3 Replies

  • Don't see any issue with iRule.

    STREAM
    function works if you will add stream profile in VIP. Try this option. Go to VIP --> Advance --> Stream Profile --> stream(default)