Forum Discussion

Rahul_Yadav's avatar
Aug 18, 2019

iRule - Pool member Failover

Hi,

 

PFB iRule.

Purpose: 1 VS for 3 application and redirection on the basis of host name.

for each application we have different Pool. If pqr.com or xyz.com not working redirect to abc.com

 

Issue: It is working perfectly if we have 3 very different URL, not working when we have one parent domain and 2 other different sub-domain.

 

when HTTP_REQUEST

{ switch -glob [HTTP::host]

 { abc.com { pool Pool_1

 }  pqr.com {

                  if  { [HTTP::uri] contains "pqr" && [active_members Pool_2]>=1 }

                      { pool Pool_2  }

                 else

                      {  HTTP::redirect http://abc.com }

             }

    xyz.com {

                  if  { [HTTP::uri] contains "xyz" && [active_members Pool_3]>=1 }

                     { pool Pool_3 }

                 else

                      {  HTTP::redirect http://abc.com }

             }                          

    default  { HTTP::redirect http://abc.com  }

}

}

 

2 Replies

  • This iRule use to default policy for sub.pqr.com request. You should use "*" character for sub-domains.

    Also, you can redirect to pool, instead of redirecting to abc.com.

    when HTTP_REQUEST {
    	switch -glob [string tolower [HTTP::host]] {
    		"abc.com" { pool Pool_1 }
    		"pqr.com" - 
    		"*.pqr.com" {
    			if  { [HTTP::uri] contains "pqr" && [active_members Pool_2] >= 1 } {
    				pool Pool_2
    			} else {
    				pool Pool_1
    			}
    		}
    		"xyz.com" -
    		"*.xyz.com" {
    			if  { [HTTP::uri] contains "xyz" && [active_members Pool_3] >= 1 } {
    				pool Pool_3
    			} else {
    				pool Pool_1
    			}
    		}
    		default { pool Pool_1 }
    	}
    }