Forum Discussion
Mike_Graston_10
Nimbostratus
Jul 13, 2007Simple Base URl rewrite
OK I have been looking at this forum and I know it's here somewhere but can't find it. My issue is I have a proxy server sitting in front of a web site http:///abc.com. I need to rewrite the url going to the proxy to http://def.com. send it to my proxy pool in my VS. then on it;s reverse path back to the client rewrite the base url back to http://abc.com. Of course this is all while keeping the uri portion in tact.
I think I am on the right track with this script but it is puzzing on the return trip.
when HTTP_REQUEST {
set userhost [HTTP::host]
if { $userhost == "abc" } {
set userhost " def "
}
any help would be appreciated.
- You are on the right track with retrieving the value with HTTP::host but you are just updating a local variable, not the actual host header that is sent. This should work for you.
when HTTP_REQUEST { if { [HTTP::host] eq "abc.com" } { HTTP::header replace "Host" "def.com" } }
- Mike_Graston_10
Nimbostratus
Thanks for the quick reply. I definately do not want the browser to know they are going to def as they couldn't resolve it anyway but if there is a link within the web stie to another page I assume they would click and the request would send the browser to the real url def. In this case the traffic being sent back ot the user would have the def in it and the browser wouldn't know what to do with it? Am I correct or am I just confusing myse3lf here? - David_Remington
Employee
xf, - Deb_Allen_18Historic F5 AccountThe webserver could be sending absolute URLs (http://def.com/path/file) or relative URLs (/path/file). Or both.
- Mike_Graston_10
Nimbostratus
Ok. - Mike_Graston_10
Nimbostratus
actually has anyone enabled a stream within an irule. I found an example on f5's web site of all places??? - Mike_Graston_10
Nimbostratus
Ok, for anyone following this I have successfully done this. I set up a stream profile and changed abc to def within the header. I also needed to setup a http profile set to rechunk then added an irule for the response going back to the browser so the user dos not know he is hitting a different url.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects