Forum Discussion

Antony2015's avatar
Antony2015
Icon for Altostratus rankAltostratus
Jun 02, 2015

HTTP:: redirection is not working in iRule

I am using 443 VIP with SSL offloading/http profle enabled. It matches all the conditions in the below irule except http::redirect condition.

 

could you please let me know what is the reason why the redirection is not working on iRule ?

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "x.y.com" } { pool x-pool } elseif { [string tolower [HTTP::host]] equals "xdev.y.com" } { pool xdev-pool } elseif { [string tolower [HTTP::host]] equals "xuat.y.com" } { pool xuat-pool } else { HTTP::redirect http://1.1.1.1:65535/ } }

 

Any help would be highly appreciated !

 

2 Replies

  • It matches all the conditions in the below irule except http::redirect condition.

    what host (fqdn) did you test?

     configuration
    
    [root@ve11a:Active:In Sync] config  tmsh list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      if { [string tolower [HTTP::host]] equals "x.y.com" } {
        pool x-pool
      } elseif { [string tolower [HTTP::host]] equals "xdev.y.com" } {
        pool xdev-pool
      } elseif { [string tolower [HTTP::host]] equals "xuat.y.com" } {
        pool xuat-pool
      } else {
        HTTP::redirect http://1.1.1.1:65535/
      }
    }
    }
    
     test
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10 -H "Host: something"
    HTTP/1.0 302 Found
    Location: http://1.1.1.1:65535/
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    
  • Requirement : The condition is if all pools are down, it should redirect to server Maintenance page

     

    the irule does not match the requirement (i.e. it does redirect when fqdn does not match predefined names). you can use active_members to check number of active pool members.

     

    active_members https://devcentral.f5.com/wiki/iRules.active_members.ashx