Forum Discussion
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
- Michael_JenkinsCirrostratus
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
to see if the url works (just to verify it's not a web server issue). So something likecurl
(or use http if you're offloading SSL and going HTTP to the web server)curl -k https://:/123/546 -v
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com