redirection but url not change on browser

Forward all http requests for http://test.abc.com/try to http://pass.xyz.com The idea here is to maintain the URL as http://test.abc.com/try on the user’s browser while the content/site served up is from http://pass.xyz.com.

Please mail me on .

You can certainly rewrite the host header between LTM and the pool member, but are you trying to transparently send the user’s info to whatever pass.xyz.com resolves to instead?

Can you please send me a iRule for this ? I will be highly thankful to you.

Something like this should work for you Dharmendra:

when HTTP_REQUEST { 
 if { [HTTP::header host] eq "test.abc.com" } { 
 HTTP::header replace Host "pass.xyz.com" 
 } 
 }

The users will still use the URL test.abc.com, their URL will stay the same and the data that is passed on to the servers will contain the new host header info.

Thanks.

I will test it .

Hi Naladar, its not working, my exact requirement is that if user type www.abc.com/aaa should redirect to www.xyz.com, latter is not in our network its some blogsite. Thanks

As far as I know, you won’t be able to do that transparently. If you could, it would be awfully easy to get around browser security measures.

It’s simple to send the user a redirect but I can’t think of a way to redirect them to a different site transparently. Maybe others will have an idea.

is it possible to reach the blog site via the pool of virtual server e.g. gateway pool?

As Nitass suggests, you could still transparently proxy requests to the second site even if it’s not directly on an LTM subnet. LTM would need to have a route to the site. You’d want to rewrite the host header on requests as Naladar has shown and select a pool with the server(s) for the second site configured. If you need to dynamically look up the IP address(es) for the second site, you could do this with an iRule which calls RESOLV::lookup (http://devcentral.f5.com/wiki/default.aspx/iRules/resolv\_\_lookup). You’d probably need to SNAT the serverside connection as well.

Aaron

Hi Aaron, actually second website is not in our domain, it is a public website like google.com, is it still possible to rewrite public url with our own url. In other words, users are seeing our url and they are actually accessing some public blogsite. Thanks

Hi Puneet,

As long as LTM has a route to the IP address(es), it doesn’t matter who “owns” the server. You can transparently proxy traffic to the site. See my post above for details on how to do this. If you try an iRule and get stuck let us know.

Aaron

Very slick Aaron!

It seems easy enough to resolve an IP address, but how exactly do you reference it? Let’s say you have an extremely dynamic environment where IP changes constantly, can you get around not having any pools/nodes defined? You’d basically want to send traffic to node x:80 where x is whatever www.sample.com resolves too.

Hi Chris,

You can use the node command to dynamically set the destination IP and port for load balancing to whatever IP you resolve the hostname to. You could update the concept from this Codeshare example to do this:

http://devcentral.f5.com/wiki/default.aspx/iRules/DestinationSnatUsingDNS.html

I like the idea of using a time based solution instead of connection counts:

http://devcentral.f5.com/wiki/default.aspx/iRules/LogEveryXSeconds.html

And you’d want to use RESOLV::lookup instead of NAME::lookup for 10.1+.

If I get some time I can try to put an example together. Else, if you want to give it a shot, it would be useful.

Aaron

Cool. Thanks Aaron! I knew pool couldn’t be dynamic but didn’t realize node could be. I’ll see what I can do.

Hi Aaron,

Thanks for insight, Can you please elaborate server side configuration, do we need seperate pool on the f5 for the server and what should be the configuration on the server, also do we need to give route on the f5 even after using resolve_lookup irule.

pls feel free to revise.

virtual bar1 {

destination 172.28.17.52:http

ip protocol tcp

rules rewrite1

profiles {

http {}

tcp {}

}

}

rule rewrite1 {

when HTTP_REQUEST {

if { [HTTP::uri] eq “/try” } {

HTTP::header replace Host “www.google.com.sg”

HTTP::uri “/”

node [RESOLV::lookup @8.8.8.8 “www.google.com.sg”] 80

} else {

pool foo1

}

snat automap

}

}

pool foo1 {

members 10.10.70.120:http {}

}

curl -I http://172.28.17.52/

HTTP/1.1 200 OK

Date: Thu, 11 Nov 2010 04:35:04 GMT

Server: Apache/2.0.59 (rPath)

Last-Modified: Thu, 11 Nov 2010 04:23:21 GMT

ETag: “1315d-5f-5580a040”

Accept-Ranges: bytes

Content-Length: 95

Content-Type: text/html; charset=UTF-8

curl -I http://172.28.17.52/try

HTTP/1.1 200 OK

Date: Thu, 11 Nov 2010 14:13:16 GMT

Expires: -1

Cache-Control: private, max-age=0

Content-Type: text/html; charset=ISO-8859-1

Set-Cookie: PREF=ID=c809c46b5959f7f0:FF=0:TM=1289484796:LM=1289484796:S=ye5asa5vGc6AHd1X; expires=Sat, 10-Nov-2012 14:13:16 GMT; path=/; domain=.google.com.sg

Set-Cookie: NID=40=ly0AIjIvqNT6hFqH3MTxoMIkkO7K6novG9ZqqqcZ5-5xzCzopkHqBeGW5QguqO6HqJFuARliJhFaInZXIZI7Jj--uQoMne7XFs5E0x_6oGhGHeJGKOCQ6s3hzIdcR3Je; expires=Fri, 13-May-2011 14:13:16 GMT; path=/; domain=.google.com.sg; HttpOnly

Server: gws

X-XSS-Protection: 1; mode=block

Transfer-Encoding: chunked

Hi Naladar, I have tried this irule but its not working, webpage is showing error.

when HTTP_REQUEST {

if { [HTTP::header host] eq “test.abc.com” and [HTTP::header uri] eq “/aaa” } {

HTTP::header replace Host “pass.xyz.com”

}

}

Hi Nitaas, I tried this rule but its not working, may be because i am using ver 9.x.x, am i right ?

Posted By Puneet on 11/11/2010 08:13 AM

Hi Nitaas, I tried this rule but its not working, may be because i am using ver 9.x.x, am i right ?

yes, i think so. the RESOLV::lookup is available in v10. can u try NAME::lookup instead? if it still does not work, would u mind posting your rule here?

Hi Nitaas, I have few quaries, what is destination address(172.28.17.52) is it server or website address, and what is 8.8.8.8 before google.com.sg.

Also, when i applied this irule as it is in irule editor then for line ‘virtual bar 1’, it showed error - ‘command is not valid in the current scope’. For HTTP_REQUEST it showed error- ‘Duplicate event/priority’. Is second error because HTTP_REQUEST is being repeated in the same irule. Thanks