Forum Discussion
siyadh_121603
Nimbostratus
Aug 14, 2014Rewrite http redirect from one VIP to another VIP
Hi,
We have to make iRule, which should redirect to another VIP in the same LTM if one specific URL trigger.
eg: request URL : http://abc/xyz
redirect URL: http://abc:40001
nitass_89166
Noctilucent
Aug 16, 2014can you try to set event priority and disable all after redirection?
priority
https://devcentral.f5.com/wiki/iRules.priority.ashxevent disable
https://devcentral.f5.com/wiki/iRules.event.ashxe.g.
// config
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
destination 172.28.24.10:80
ip-protocol tcp
mask 255.255.255.255
pool foo
profiles {
http { }
tcp { }
}
rules {
qux
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vs-index 63
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
when HTTP_REQUEST priority 100 {
if { [HTTP::path] starts_with "/xyz" } {
HTTP::redirect "http://[HTTP::host]:40001/"
event disable all
}
}
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar40001
ltm virtual bar40001 {
destination 172.28.24.10:40001
ip-protocol tcp
mask 255.255.255.255
pool foo40001
profiles {
tcp { }
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vs-index 64
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo40001
ltm pool foo40001 {
members {
200.200.200.101:40001 {
address 200.200.200.101
}
}
}
// test
[root@ve11a:Active:In Sync] config curl -IL http://172.28.24.10/xyz/something
HTTP/1.0 302 Found
Location: http://172.28.24.10:40001/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
HTTP/1.1 200 OK
Date: Sat, 16 Aug 2014 08:24:04 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT
ETag: "41879c-59-2a9c23c0"
Accept-Ranges: bytes
Content-Length: 89
Connection: close
Content-Type: text/html; charset=UTF-8
siyadh_121603
Nimbostratus
Aug 18, 2014Hi Nitass,
Thank you for your guidance and support.
This iRules works fine
when HTTP_REQUEST {
if {([string tolower [HTTP::uri]] contains "/xyz") and [string tolower [HTTP::host]] equals "abc"}{
HTTP::redirect http://abc:40001;
}
}
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