Forum Discussion

extremeboozer_3's avatar
extremeboozer_3
Icon for Nimbostratus rankNimbostratus
Oct 23, 2007

Insert new URL

Even though myself and my co-worker pride ourselves in being rule hacks we still have yet to figure out how to write a rule to change the destination URL of an HTTP request without redirecting the clients browser. Hope this makes sense to someone else but me.

 

 

thanks for the help

 

 

3 Replies

  • A HTTP::redirect will issue a full HTTP redirect to the client browser, change the address bar, and have the browser send a new request to the server. This is likely what you have discovered. If you wish to just "change" the URI so the backend server sees something different than the client browser, you can do so with a combination of the "Host" header and the HTTP::uri command.

    Here's an example:

    when HTTP_REQUEST {
      HTTP::header replace "Host" "foobar.com"
      HTTP::uri "/some/new/path"
    }

    This will turn any request you send to the virtual server, into this into the backend

    http://foobar.com/some/new/path

    without sending a redirect to the client. The client still thinks he's going to http://coolstuff.com/buysomething.

    Of coarse, you can do either the Host Or the URI or both if you want, I just illustrated how to do it for the full URI.

    Check out the wiki docs on those two methods for more info.

    -Joe
  • Joe, I appreciate you quick response to a newbie. But I just must be really dull.

     

    I have a virtual server configured with a client side ssl cert. Configured with an address on port 443. For resources I have none for pool and persistence. Under iRules I have my Host_replace rule.

     

    here is my rule:

     

    when HTTP_REQUEST {

     

    HTTP::header replace "Host" "share.stg.myxx.com"

     

    HTTP::uri "/Pages/Default.aspx"

     

    }

     

    I go to https://bt.dev.myxx.com, but it cannot display a page. I can change the rule to a redirect and that works fine so I think that the virtual and proxy are configured correctly.

     

    I have also tried :

     

    when HTTP_REQUEST {

     

    if { [HTTP::host] eq "bt.dev.myxx.com" } {

     

    HTTP::header replace "Host" "share.stg.myxx.com"

     

    }

     

    }

     

    Still no love.

     

    Does this have something to do with SSL? Please help.

     

     

    ~Bo