Forum Discussion

Krishna_251070's avatar
Krishna_251070
Icon for Nimbostratus rankNimbostratus
Oct 08, 2017

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

  • Hi,

    looking at your virtual server, there is the profile fastl4 assigned... this is the issue.

    change the virtual server type to

    Standard
    instead of
    Performance HTTP
    !

  • I agree with you.

     

    Krishna, can you please let us know for what reason fastl4 is configured on VIP.