Forum Discussion

Scott_83827's avatar
Scott_83827
Icon for Nimbostratus rankNimbostratus
Apr 10, 2012

Log Not Showing Modified URI

The script below works properly. If the uri contains /hh/ then changes the extention from .cfm to .aspx and sends the request to the MigrationPool pool. So if you go to http://nowhere.com/hh/test.cfm it should send the request to http://nowhere.com/hh/test.aspx. It does this correctly. However, when I log the URI it shows the old URI in the log:

 

 

Rule Test1 HTTP_REQUEST: Migration Pool: /hh/news.cfm

 

 

I would expect it to say:

 

 

Rule Test1 HTTP_REQUEST: Migration Pool: /hh/news.aspx

 

 

Any ideas on why it does this?

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "/hh/" } {

 

HTTP::uri [string map -nocase {.cfm .aspx} [HTTP::uri]]

 

log local0. "Migration Pool: [HTTP::uri]"

 

pool MigrationPool

 

} else {

 

log local0. "Current Production: [HTTP::uri]"

 

pool CurrentProduction

 

}

 

}

 

 

Thanks,

 

Scott

 

  • Notes

     

    Beginning in version 11, the cached behavior changes so that the value of the uri is updated immediately after being set. Previously, you would need to log the value in a higher priority (read: higher number) of the current event or log the value in a later event in order to reflect the change.HTTP::uri wiki

     

    https://devcentral.f5.com/wiki/iRules.HTTP__uri.ashx

     

     

    hope this help.
  • I don't understand what "log the value in a higher priority" means in this case.

     

     

    Does that mean that should use:

     

    log local1. "Migration Pool: [HTTP::uri]"

     

     

    Thanks,

     

    Scott
  • Hi Scott,

    The comment from the [HTTP::uri] wiki page is saying that when you are using the Priority inside of an iRule it can impact the output of what you are trying to log.

    The Priority Command can be used for events inside of an iRule or on the entire iRule in cases where you have numerous iRules applied to a single Virtual Server.

    The easiest way to see what it is describing is to create one iRule that will log the value of the incoming [HTTP::uri] and then log it.

    Then create a second iRule that will just log the value of the [HTTP::uri], and put this iRule BELOW the first.

    The first iRule will log and modify the value, and the second will display the results set by the first.

    You could accomplish the same results by setting the iRule Priority (which would negate the order of the iRules in the list).

     
    First iRule:
    when HTTP_REQUEST {
    log local0. "First iRule HTTP::uri Value:  [HTTP::uri]"
    HTTP::uri "/something"
    }
    
    Second iRule:
     when HTTP_REQUEST {
    log local0. "Second iRule HTTP::uri Value:  [HTTP::uri]"
    }
    

    Hope this helps.
  • Sorry,

    I forgot to show that the value of the [HTTP::uri] of the Post [HTTP::uri] modification in the iRule is still the same. The value is cached and that value is returned before and after the modification.

    It is not until the second iRule that the modified value is displayed.

     
    First iRule:
    when HTTP_REQUEST {
    log local0. "First iRule HTTP::uri Value:  [HTTP::uri]"
    HTTP::uri "/something"
    log local0. "First iRule, Post HTTP::uri Modification:  [HTTP::uri]"
    }
    
    Second iRule:
    when HTTP_REQUEST {
    log local0. "Second iRule HTTP::uri Value:  [HTTP::uri]"
    }
    

    If you want to dig into it further the Priority Command is worth learning since it can help you insure that certain events are executed in a specific order, regardless of the listed iRule order in the Command Console.

    Hope this helps.
  • Ok, I understand now and I can see the correct value. Thank you for the explanation.

     

     

    Scott
  • As Michael and Nitass said, in pre-v11.0, many HTTP:: commands were cached in the same iRule event. To see the updated value in a single iRule you could use a later priority iRule event:

    
     See priority wiki page for details: https://devcentral.f5.com/wiki/iRules.priority.ashx
    when HTTP_REQUEST {
        log local0. "Original \[HTTP::uri\] value:  [HTTP::uri]"
        HTTP::uri "/something"
    }
    when HTTP_REQUEST priority 501 {
        log local0. "Updated \[HTTP::uri\] value:  [HTTP::uri]"
    }
    

    Aaron