Forum Discussion
iRule not working
Hi Experts,
I am trying to learn how iRule works. So I wrote a simple iRule and assigned that to a Virtual server; but for some reason its not working. 😞
I am trying to get page redirect with any HTTP return status code.
user@(ltm-02)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule AWS
ltm rule AWS {
when HTTP_RESPONSE {
if { [HTTP::status] contains "200" || [HTTP::status] contains "404" } {
HTTP::redirect "http://www.google.com/"}
}
}
user@(ltm-02)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual AWS
ltm virtual AWS {
destination 10.10.11.65:http
ip-protocol tcp
mask 255.255.255.255
pool AWS
profiles {
fastL4 { }
http { }
}
rules {
AWS
}
source 0.0.0.0/0
source-address-translation {
type automap
}
translate-address enabled
translate-port enabled
vs-index 6
}
TEST RESULTS:
user@(ltm-02)(cfg-sync In Sync)(Active)(/Common)(tmos) run util bash
[user@ltm-02:Active:In Sync] ~ curl -IL http://10.10.11.65
HTTP/1.1 200 OK
Server: nginx/1.12.1
Date: Sun, 08 Oct 2017 18:20:24 GMT
Content-Type: text/html
Content-Length: 3770
Last-Modified: Mon, 11 Sep 2017 19:56:09 GMT
Connection: keep-alive
ETag: "59b6ea59-eba"
Accept-Ranges: bytes
[user@ltm-02:Active:In Sync] ~ curl -IL http://10.10.11.65/donotexist
HTTP/1.1 404 Not Found
Server: nginx/1.12.1
Date: Sun, 08 Oct 2017 18:20:34 GMT
Content-Type: text/html
Content-Length: 3696
Connection: keep-alive
ETag: "59b6ea59-e70"
[user@ltm-02:Active:In Sync] ~
I expected the page to redirect to google.com when I hit http://10.10.11.65. But for some reason its not working.
2 Replies
- Stanislas_Piro2
Cumulonimbus
Hi,
looking at your virtual server, there is the profile fastl4 assigned... this is the issue.
change the virtual server type to
instead ofStandard
!Performance HTTP - RaghavendraSY
Altostratus
I agree with you.
Krishna, can you please let us know for what reason fastl4 is configured on VIP.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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