JimmyJose
Feb 25, 2016Nimbostratus
Pool selection using iRule
Hello,
An application is hosted on ports 8443 and 8445.
I am trying to achieve the following using iRule.
- URL attempted is http://abc.domain.com
- It should be redirected to https://abc.domain.com/123/456, and the traffic should be sent to POOL-1.
- Pages from https://abc.domain.com/123/789 are also attempted, which also, should also be sent to POOL-1.
- The login page is now loaded. After keying in the credentials, it goes to https://abc.domain.com/999, which should be sent to POOL-2.
Tried the following 2 iRules. Observation is that the redirect to https://abc.domain.com/123/456 is attempted, but fails.
=-=-=
when HTTP_REQUEST {
if {[HTTP::uri] equals "/"}{HTTP::redirect "https://[HTTP::host]/123/456" pool POOL-1} elseif {[HTTP::uri] ends_with "/999/*"}{POOL-2} }
=-=-=
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { / {HTTP::redirect "https://[HTTP::host]/123/456"} /123/456 {pool POOL-1} /999/* {pool POOL-2} } }
=-=-=
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/999/*" { pool POOL-2 } "/" {HTTP::redirect "https://[HTTP::host]/123/456"} } }
and in this case, set the default pool to POOL-1 in the virtual server.
=-=-=
Am I making any mistakes in the iRules?
-Jimmy