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
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
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?
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 "}
}
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.
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"
}
}
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.
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.
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.
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
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:
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
}
}
}
Understand that the [HTTP::uri] is going to produce a new URI that is transparent to the user. So if the user makes a request for “/news/foo/bar”, the server will see “/foo/bar”, and the client’s address bar will not change. There is a minor typo in the above iRule though. It should actually look like this:
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
if { [string tolower [HTTP::uri] equals "/news" } {
HTTP::uri "/"
else {
HTTP::uri [string map {"/news" ""} [HTTP::uri]]
}
}
default {
pool www.abc.com-pool
}
}
}
The previous version would have mapped “/news/foo/bar” to “//foo/bar” (an extra forward slash).
everytime I add the line it apends a www.www.abc.com to the front of it
I’m not sure what this means.
Minor typo:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/news*" {
pool news.xxx.com-pool
if { [string tolower [HTTP::uri]] equals "/news" } {
HTTP::uri "/"
else {
HTTP::uri [string map {"/news" ""} [HTTP::uri]]
}
}
default {
pool www.abc.com-pool
}
}
}
there where some missing braces. not sure if I got them in the right space… but if I now go to www.abc.com/news the url changes to www.www.abc.com its crazy…
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/news*" {
pool news.xxx.com-pool
if { [string tolower [HTTP::uri]] equals "/news" } {
HTTP::uri "/"}
else {
HTTP::uri [string map {"/news" ""} [HTTP::uri]]
}
}
default {
pool www.abc.com-pool
}
}
}
There’s nothing in this iRule that would cause that. I think at this point it’d make sense to fire up a client side HTTP analyzer (ie. Fiddler or HTTWatch) and see where this information is coming from.
well, it looks like the www.abc.com/news is getting a HTTP/1.1 301 Moved Permanently and the Server: Apache(end server is IIS) then going to www.www.abc.com/ not much to go on… I used fiddler(first time)… but in a last look I added the DNS for www.www.abc.com and funny thing… its the end server at the 3rd party.. I guess they have a rule adding www. to requests coming into there server.. I got a full website also hosted with the 3rd party. they should be recieving new.800loanmar.com/ but I dont think they are.. if Im getting that redirect.
HTTP/1.1 301 Moved Permanently
Date: Tue, 12 Nov 2013 13:50:42 GMT
Server: Apache
Location: http://www.www.abc.com/
Content-Length: 247
Connection: close
Content-Type: text/html; charset=iso-8859-1
301 Moved Permanently
Moved Permanently
The document has moved here.
Very odd that they’re trying to add a “www” to something that already starts with “www”. They should perhaps spend more time on DevCentral. ![]()
In any case, you might be able to thwart this if you modify the Host header to them in a fashion that they’ll accept without throwing a redirect.
Im going to push for them to make a new main directory under news.xxx.com/news then it will all work. Im mean really… add a www to a www.. these people need more busy work.
thanks for all the help… Its always nice to know I have people to bounce things off.