Forum Discussion
transparent redirect question
Hi,
I want to take a request to a domain that contains a string and redirect based on that string without the client knowing a redirect took place (ie. getting different content based on that string - rather than being redirected based on that string)
The other part is that string needs to be removed during that request, because it doesn't actually exist.
Based on other stuff in devcentral, I was trying the following code, but it seems to be doing the exact opposite of what I want, its rewriting the header on the client side but pulling the data from the original host.
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] contains "/11string11"}
{
set uri [string map {"/11string11" ""} [HTTP::uri] ]
HTTP::header replace "Host" "beta-s.domain.com"
HTTP::uri "$uri"
}
}
beta-s.domain.com is just a host out somewhere else not another vip/pool
So my goal is to have the request for http://s.domain.com/11string11/junk.txt return the content from http://beta-s.domain.com/junk.txt while keeping the original name on the client.
- Colin_Walker_12Historic F5 AccountAre you looking to do this for just a single host/uri combination, or several? It would change the approach a fair amount if there were many of these. Also, do you need to re-write content (links, image source addresses, etc.) inside the document that you're serving from behind the altered host/uri?
- sidiov
Nimbostratus
Technically its for 2 hosts, but right now I was doing them in seperate irules since the original sites are seperate VIPs. I dont imagine I would need to go beyond a single host rewrite per site. (Its just used for developers to test a beta version of that site using a production caching layer)
- nitass
Employee
the rule looks just fine for me. may you capture packet to see what is going on?[root@ve1023:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve1023:Active] config b pool foo list pool foo { members 200.200.200.101:80 {} } [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/11string11"}{ set uri [string map {"/11string11" ""} [HTTP::uri] ] HTTP::header replace "Host" "beta-s.domain.com" HTTP::uri "$uri" } } } [root@ve1023:Active] config ssldump -Aed -nni 0.0 port 80 New TCP connection 1: 172.28.19.253(38669) <-> 172.28.19.79(80) 1326337897.9044 (0.0018) C>S --------------------------------------------------------------- HEAD /11string11/junk.txt HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8r zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.79 Accept: */* --------------------------------------------------------------- New TCP connection 2: 200.200.200.10(38669) <-> 200.200.200.101(80) 1326337897.9064 (0.0009) C>S --------------------------------------------------------------- HEAD /junk.txt HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8r zlib/1.2.3 libidn/0.6.5 Host: beta-s.domain.com Accept: */* ---------------------------------------------------------------
- sidiov
Nimbostratus
edit
I tried with an apache box as the target, and noticed that the host and uri is getting changed but the content is still coming from the original (iis) servers
- nitass
Employee
But I want to load the content from the other server whether it exists in the first domain or not.if you want to send traffic to another server (pool member), can you try node command?when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/11string11"}{ set uri [string map {"/11string11" ""} [HTTP::uri] ] HTTP::header replace "Host" "beta-s.domain.com" HTTP::uri "$uri" node x.x.x.x 80 } }
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