Forum Discussion
Stealth Redirection or URL Hiding
Im not sure you can do this, but I will ask. looking to take www.abc.com/news and have the uri /NEWS actually be news.xxx.com(site is third party)
Thanks
- Kevin_StewartEmployee
May I ask why you're calling it "stealth redirection"? Do you need to physically redirect the user to a different URL elsewhere, or change the URI and host header, and then forward the traffic through the proxy to a remote host?
- F5Hopper_28651Nimbostratus
it was explained to me as steath redirection....from dev.
I can redirect the URL to the new one.. but they dont want to see the news.xxx.com only www.abc.com/news
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/news" } { HTTP::redirect "http://news.xxx.com "} }
- Kevin_StewartEmployee
Then you'd need to use the HTTP::uri command to change the ingress URI and HTTP::header replace Host command (as required) to change the Host header. Because you don't want the user to see this new URL, you necessarily need to pass the traffic through the F5, either with an established pool or the node command in the iRule.
- F5Hopper_28651Nimbostratus
so since the news.xxx.com is some blog server somewhere outside my control I wouldnt be able to do this?
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/news"} { HTTP::redirect "http://news.xxx.com " } elseif { [HTTP::header host] eq "news.xxx.com" } { HTTP::header replace Host "www.abc.com/news" } }
- Kevin_StewartEmployee
The problem basically boils down to DNS and HTTP protocol characteristics. When you issue a redirect to a browser, you're sending it a 30x status message with a Location header with a URL. That combination causes the browser to resolve this address and then navigate directly to it. This will also cause the browser's address bar to change. The www.abc.com and news.xxx.com servers live in different places and resolve to different IP addresses, so if you need the browser address bar to stay the same, you have to force all of the traffic through your proxy.
Addressing your iRule, the first part will send the browser off to news.xxx.com if the request is for www.abc.com/news. The second part, the elseif clause, will never happen because a browser request for news.xxx.com will never go through your proxy.
This leaves you with about two options:
-
Force the news.xxx.com traffic through your proxy by maintaining the www.abc.com URL and sending to a pool or node.
-
Less of a proxy solution, you could maintain the www.abc.com URL and use Ajax to asynchronously collect the news.xxx.com content and render locally. This would obviously require a lot more dev work on your part, so option 1 is going to be much easier.
-
- F5Hopper_28651Nimbostratus
so I setup news.xxx.com on my F5. I tested it and it works just fine.
but if I add my irule to it to change the header it doesnt work.
when HTTP_REQUEST { if { [string tolower [HTTP::header "Host"]] equals "news.xxx.com" } { HTTP::header replace Host "www.abc.com/news" return } }
the chrome and ie browsers still show news.xxx.com in the URL area.
- Kevin_StewartEmployee
the chrome and ie browsers still show news.xxx.com in the URL area
And they are going to. You're replacing the Host header as the request flows through the proxy. The client isn't going to see this. The server will though. The Host header is just that, an HTTP header. It's a value in the HTTP request, and has basically nothing to do with browser navigation. In fact in HTTP/1.0 the Host header isn't even required.
- F5Hopper_28651Nimbostratus
update- I was able to get the look we needed. once we proxy hosted the news.xxx.com I could then send the traffic to the pool.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host][HTTP::path]] { "www.abc.com/news*" { pool news.xxx.com-pool } default { pool www.abc.com-pool } } }
now I have to work with the 3rd party to fix the uri they now recieve. they now get stuff to news.xxx.com/news and they dont have that directory(but the core site is there) and also once anyone clicks a link on that site it would change there URL to the real site. But I think I might be able to fix that with some general irule redirects.
Heading - Kevin_StewartEmployee
Or perhaps something like this:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/news*" { pool news.xxx.com-pool HTTP::uri [string map {"/news" "/"} [HTTP::uri] } default { pool www.abc.com-pool } } }
If the URI starts with "/news", send to the news pool and strip the "/news" portion of the URI. You're still going to run into problems though. If the news host makes local references to content (images, links, JavaScript, style sheets, etc.) that don't start with "/news", your iRule won't know which direction to send the traffic when the client makes a request for that content. And since everything is going to the same host (www.abc.com), you might necessarily have to:
-
Ask the news host to put everything behind a "/news" URI structures - easy for you but difficult for them.
-
Rewrite all URI references that come from the news host to add the "/news" portion to the URI - easy for them but (a little) difficult for you.
-
- F5Hopper_28651Nimbostratus
funny thing, everytime I add the line it apends a www.www.abc.com to the front of it..but I dont have a rule adding a www to my test virtual server
I tried to change this(HTTP::uri [string map {"/news" "/"} [HTTP::uri]]) where "/" is "/hi" and it doesnt work.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/news*" { pool news.xxx.com-pool HTTP::uri [string map {"/news" "/"} [HTTP::uri]] } default { pool www.abc.com-pool } } }
Recent Discussions
Related Content
* 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