Forum Discussion
joelvs_45274
Nimbostratus
Sep 14, 2007Redirect HTTP traffic without modifying url
Hello,
I am repeatedly getting requests from my developers to have blah.domain.com display a page that is at www.domain.com/uri without changing the original url. They want the original url to remain blah.domain.com in the browser.
I am running version 9.4 and have tried to do this various ways without success. Can anyone give me some pointers on the best way to do this. It may very well be that I am just making this a lot harder than it needs to be.
3 Replies
- Let's assume your external hostname is "blah.domain.com" and your internal servers are configured with a hostname of "www.domain.com", then you can use simple host name header rewriting to do the trick.
when HTTP_REQUEST { if { [HTTP::host] eq "blah.domain.com" } { HTTP::header replace "Host" "www.domain.com" } }
This will change the Host header going to the backend webserver from blah.domain.com to "www.domain.com" so a request for "http://blah.domain.com/foobar" would look like "http://www.domain.com/foobar" to the backend server.
Now for your specific question, you mention that you would like "blah.domain.com" to be treated like "www.domain.com/uri. It's a bit unclear on whether you are asking to redirect all "http://blah.domain.com/something" requests to "http://www.domain.com/fixeduri" where "something" and "fixeduri" are different values or whether you are just asking to keep the uri portion of the request the same. If it's the same, then the above iRule will work for you as it doesn't modify the original URI.
Now if you did want to map all incoming requests to a fixed URI, you could do something like the following:when HTTP_REQUEST { if { [HTTP::host] eq "blah.domain.com" } { HTTP::header replace "Host" "www.domain.com" HTTP::uri "/fixedvalue" } }
This will turn all requests to "http://blah.domain.com/..." to "http://www.domain.com/fixedvalue".
Since these iRules are just modifying HTTP header values to the backend server, they will not be reflected in the browsers address bar as they would if being sent a HTTP redirect.
Let me know if this suits your needs and if not, some more concrete examples of mappings you want to perform.
-Joe - Kirk_Bauer_1018
Altostratus
The only downside to Joe's suggestions are redirects. For example, let's say that the user types in blah.domain.com/support and the Host header is changed so the web server sees www.domain.com/support. Let's assume support is a directory. The web server will now redirect the browser to http://www.domain.com/support/. So you also need to modify the URI in the redirects so that the client sees http://blah.domain.com/support/.
I believe everything you need to do can be quickly accomplished with my ProxyPass iRule (http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPass.html). The rule itself is fairly complex but you should not need to modify it. Instead just create the data group as described in the instructions and the rule will take care of the rest. If the rule doesn't do what you want let me know and I'll review your configuration, etc. - joelvs_45274
Nimbostratus
ProxyPass worked great for what i needed in 9.x, is there an easy way to do the same thing in 4.x?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
