Forum Discussion

Alexandre_Levac's avatar
Icon for Nimbostratus rankNimbostratus
Oct 17, 2018

IRule vs LTM Policy : Replace command not working


We actually use an IRule to manage different API in my organization.

For maintaining purposes, it would be simpler to use an LTM Policy instead. I have tried to configure an LTM Policy to do the equivalent of my IRule, but it doesn't seem to be working.


    switch -glob [string tolower [HTTP::uri]] {         
        "/service1/feature1/*" {            
             Client request:*
             Server request:   http://servername:12345/api/*
            HTTP::path [string map -nocase {"/service1/feature1/" "/api/"} [HTTP::path]]
            pool service1_feature1_pool   

LTM Policy equivalent:

Match all of the following conditions:
[HTTP URI][path][begins with] any of [/service1/feature1/]

Do the following when the traffic is matched: 
[Replace][http uri][path][/service1/feature1/] with value [/api/]
[Forward traffic] to [pool][service1_feature1_pool]

The [Forward traffic] part works well with the LTM Policy. But when I add the [Replace] line, it doesn't seem to replace the [Path] in the way I want to do the server side request.

Am I doing something wrong ? Is there a known issue with the [Replace] command in LTM Policies ?

Thanks for your help!