Forum Discussion

JimmyJose's avatar
JimmyJose
Icon for Nimbostratus rankNimbostratus
Feb 25, 2016

Pool selection using iRule

Hello,

 

An application is hosted on ports 8443 and 8445.

 

I am trying to achieve the following using iRule.

 

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

 

1 Reply

  • If you specify POOL-1 as the default pool, then I'd use the last iRule like this:

    when HTTP_REQUEST { 
        log local0. "Host: [HTTP::host]"
        log local0. "URI: [HTTP::uri]"
        switch -glob [string tolower [HTTP::uri]] { 
            "/" {
                log local0. "  /: Redirect to /123/456"
                HTTP::redirect "/123/456"
                return
            }
            "/999/*" {
                log local0. "  /999/*: Pool POOL-2"
                pool POOL-2 
            }
        }
    }
    

    If you're having trouble with request, then you could check it from the CLI using

    curl
    to see if the url works (just to verify it's not a web server issue). So something like
    curl -k https://:/123/546 -v
    (or use http if you're offloading SSL and going HTTP to the web server)