Forum Discussion
Mike_129800
Nimbostratus
Jul 07, 2013Redirect to different host and port based on URL
Hi
We just installed two F5 BigIP (LTM) devices so I am new to iRules, how would I setup the following redirect based on the incoming URL?
https://host.com/product1 redirect to https://host...
nitass
Employee
Jul 08, 2013I want to only replace part of the URL i.e. sto, cph, bru, jnb with WOS will the above work for that?e.g.
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
/sto { set newhost "sto.domain";set newnode "200.200.200.101" }
/cph { set newhost "cph.domain";set newnode "200.200.200.102" }
/bru { set newhost "bru.domain";set newnode "200.200.200.103" }
/jnb { set newhost "jnb.domain";set newnode "200.200.200.104" }
default {
do something
}
}
HTTP::header replace Host $newhost
HTTP::uri [string map {sto WOS cph WOS bru WOS jnb WOS} [HTTP::uri]]
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(38378) <-> 172.28.19.252(80)
1373275574.5080 (0.0007) C>S
---------------------------------------------------------------
GET /sto 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(38378) <-> 200.200.200.101(6500)
1373275574.5103 (0.0010) C>S
---------------------------------------------------------------
GET /WOS 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: sto.domain
---------------------------------------------------------------
you may use -glob switch option in case uri is not exact uri.
iRules 101 - 04 - Switch by Joe Pruitt
https://devcentral.f5.com/tech-tips/articles/irules-101-04-switch
The set newnode "200.200.200.101" should that be the IP of new hostyes
What is the virtual bar config for in the above example?it is standard virtual server with http profile. there is no pool because node command is used to send traffic to pool member.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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