Forum Discussion

gaza_104946's avatar
gaza_104946
Icon for Nimbostratus rankNimbostratus
Jul 27, 2011

HTTP::path not updating within iRule

Running 10.2 HF2

 

 

I originally had a iRule that was rewriting incoming requests

 

 

if { [HTTP::path] equals "/abc" } {

 

log local0. "[virtual name] [IP::client_addr] detected old path /abc and modified to /xyz"

 

HTTP::path "/xyz"

 

}

 

 

Which was working fine and the back-end server was seeing /xyz

 

I then need to LB to different back-ends based on the path and added this extra code

 

 

switch -glob [HTTP::path] {

 

"/abc" { pool pool_abc }

 

"/xyz" { pool pool_xyz }

 

}

 

 

What I found is that the correct pool was not being used.

 

I then moved the 2nd set of code to another iRule which was placed after the original iRule for the VS and it worked!!

 

 

Further investigation showed that if you set HTTP::path within an iRule that you don't get the new value, but a following iRule will get the new value.

 

Is there a way I can get around this as I'd like to simplify the configuration back into a single irule?

 

Note: that this is not the only code in the iRule or the only iRule, so I really am looking for a code solution rather than using HTTP classes.
  • Hi Gaza,

    Most HTTP:: commands are cached within the same event and priority. So what you're seeing is expected. If you want to use the modified value of after changing the path with HTTP::path, you can save it to a variable:

    when HTTP_REQUEST {
       if { [HTTP::path] equals "/abc" } {
          log local0. "[virtual name] [IP::client_addr] detected old path /abc and modified to /xyz"
          set path "/xyz"
          HTTP::path $path
       }
       switch $path {
          "/abc"  { pool pool_abc }
          "/xyz"  { pool pool_xyz }
       }
    }
    

    Aaron
  • Thanks Aaron,

     

     

    I suppose I just needed that confirmed as I didn't find anything on the site.

     

     

    Cheers