Forum Discussion
Dharmendra_2243
Nimbostratus
Nov 09, 2010redirection 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 .
35 Replies
- Chris_Miller
Altostratus
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.
- hoolio
Cirrostratus
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 - Chris_Miller
Altostratus
Cool. Thanks Aaron! I knew pool couldn't be dynamic but didn't realize node could be. I'll see what I can do. - Puneet_73909
Nimbostratus
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. - nitass
Employee
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 - Puneet_73909
Nimbostratus
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"
}
} - Puneet_73909
Nimbostratus
Hi Nitaas, I tried this rule but its not working, may be because i am using ver 9.x.x, am i right ? - nitass
Employee
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? - Puneet_73909
Nimbostratus
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 - nitass
Employee
172.28.17.52 is VS
8.8.8.8 is google's dns server
the vs name is bar1 (no space)
for the duplicate event/priority, i think so.
this is name::lookup version. btw, i'm not an irule geek, so pls feel free to revise.
additionally, i'd to do workaround in sol12224 to make it work. not sure if u r also affected.rule rewrite1 { when HTTP_REQUEST { HTTP::collect NAME::lookup www.google.com.sg } when NAME_RESOLVED { if { [HTTP::uri] eq "/try" } { HTTP::header replace Host "www.google.com.sg" HTTP::uri "/" node [NAME::response] 80 } else { pool foo1 } snat automap HTTP::release } }curl -I http://172.28.17.52/ HTTP/1.1 200 OK Date: Thu, 11 Nov 2010 21:55:22 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: Fri, 12 Nov 2010 07:33:33 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=ISO-8859-1 Set-Cookie: PREF=ID=e40991f367f510d5:FF=0:TM=1289547213:LM=1289547213:S=bVEofxfbPnH_AqIz; expires=Sun, 11-Nov-2012 07:33:33 GMT; path=/; domain=.google.com.sg Set-Cookie: NID=40=B-e9hc0zXAsdNidK4kGtlOygUbTNnSpTbeFSLO-SBWuVFwJHLkFRS06HMhBd9P53OexMLwpqPhIu78x3r4Iattx-dpVKlyKrNwr6_Lvc9iXYSR_wpGfP1inkfQ8PAnLo; expires=Sat, 14-May-2011 07:33:33 GMT; path=/; domain=.google.com.sg; HttpOnly Server: gws X-XSS-Protection: 1; mode=block Transfer-Encoding: chunked
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
