Forum Discussion
nitass
Jul 08, 2013Employee
i think you mean host and uri rewriting rather than redirection.
Redirects, Rewrites and App Transfers via iRules by Colin Walker
https://devcentral.f5.com/tech-tips/articles/redirects-rewrites-and-app-transfers-via-irules
e.g.
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
destination 172.28.19.252:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
/product1 { set newhost "host1.com";set newnode "200.200.200.101" }
/product2 { set newhost "host2.com";set newnode "200.200.200.102" }
/product3 { set newhost "host3.com";set newnode "200.200.200.103" }
/product4 { set newhost "host4.com";set newnode "200.200.200.104" }
default {
do something
}
}
HTTP::header replace Host $newhost
HTTP::uri "/product"
node $newnode 6500
}
}
[root@ve10:Active] config ssldump -Aed -nni 0.0 port 80 or port 6500
New TCP connection 1: 172.28.20.17(38342) <-> 172.28.19.252(80)
1373241702.9550 (0.0010) C>S
---------------------------------------------------------------
GET /product1 HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host:host.com
---------------------------------------------------------------
New TCP connection 2: 200.200.200.10(38342) <-> 200.200.200.101(6500)
1373241702.9562 (0.0011) C>S
---------------------------------------------------------------
GET /product HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host:host1.com
---------------------------------------------------------------