Forum Discussion

Thomas_Uczekaj_'s avatar
Thomas_Uczekaj_
Icon for Nimbostratus rankNimbostratus
Jun 08, 2006

Can you hide a URI change from client

Here is the sample Irule:

 

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] equals "/"} {

 

HTTP::uri /stuff }

 

}

 

 

It does this:

 

client submits: http://host.testing.com

 

client receives: http://host.testing.com/stuff/index.htm

 

 

This is what we want it to do:

 

client submits: http://host.testing.com

 

client receives: http://host.testing.com/index.htm

 

 

Anyone have an idea how to do that (hide the change in the URI)?

 

 

Tom
  • What I'm looking for is the ability to change the URI on the Response, however, HTTP::uri only works on HTTP_REQUEST not for HTTP_RESPONSE

     

     

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account

     

    If you are re-writing the URI inbound, and wish to hide the change from the client, no changes to the HTTP response should be necessary.

     

     

    If instead you want to re-write all the links on the page in HTTP_RESPONSE, exposing the new hostname and URI to the client on subsequent requests, you can use regsub & HTTP::payload replace against the response. (See the 2nd example on the HTTP::payload wiki page here: Click here)

     

     

    HTH

     

    /deb
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    If you are using 9.2 or later version, the use of HTTP::payload should be depricated in favor of the stream profile which is more powerful and much more efficient. Read all about it here Click here
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Support recently informed me of a known issue with the stream profile: The stream profile apparently does not update the Content-Length to the new size of the resulting content.

     

     

    Until that's corrected, I've been avoiding the stream profile for replacements where the content length will change.

     

     

    /deb
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    I don't believe uczekajt is looking for content re-writing, just URI re-writing from the client's perspective.

    In which case you'd do something to the effect of:

    
    when HTTP_REQUEST {
      if { [HTTP::uri] equals "/" } {
        HTTP::uri "/stuff"
      }
    }
    when HTTP_RESPONSE {
      if { [HTTP::header location] contains "/stuff" } {
        set newLoc [string map {/stuff /} [HTTP::header location] ]
        HTTP::header replace location "$newLoc"
      }
    }

    This would, of course, require re-writing each request and response.

    Colin
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    sorry, I forgot there was a cross-post. Issue further discussed & resolved here:

     

     

    /deb
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Also, apparently the workaround for the Content-Length update issue with the stream profile is to enable response chunking to rechunk in the http profile.

     

     

    /deb