Forum Discussion
Chris_Olson
Nimbostratus
Nov 10, 2006URI and pool redirection
Having trouble with the following iRule. Any help is appreciated.
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { $uri starts_with "/app1" } {
HTTP::uri [string map -nocase {"/app1" "/prod/login.cmdx"} $uri]
Pool Prod_EE_11
}
Elseif { $uri starts_with "/app2" } {
HTTP::uri [string map -nocase {"/app2" "/prod/login.cmdx"} $uri]
Pool Prod_EE_10
}
Else {
HTTP::uri [string map -nocase { * "/app1/login.cmdx"} $uri]
Pool Prod_EE_11
}
}
- hoolio
Cirrostratus
What trouble are you having? You can add some log statements to see which condition is being met and what change is being made to the URI:when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] if { $uri starts_with "/app1" } { log local0. "\$uri was $uri" HTTP::uri [string map -nocase {"/app1" "/prod/login.cmdx"} $uri] pool Prod_EE_11 } elseif { $uri starts_with "/app2" } { log local0. "\$uri was $uri" HTTP::uri [string map -nocase {"/app2" "/prod/login.cmdx"} $uri] pool Prod_EE_10 } else { log local0. "\$uri was $uri" HTTP::uri [string map -nocase { * "/app1/login.cmdx"} $uri] Pool Prod_EE_11 } }
- Chris_Olson
Nimbostratus
While the below script compiles OK., it does not function as needed. Adding the suffix to the end of the URI only works if you manually type in HTTPS. I'm guessing this has to do with this script itself or another redirect script. Here is the situation: - Have you looked at the logs? If typing in the https:// is working but using your redirect is not, then there are a couple of options:
when HTTP_REQUEST { set redir_url https://[getfield [HTTP::host] ":" 1][HTTP::uri] log local0. "redirecting to $redir_url" HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] log local0. "found uri: $uri" if { $uri starts_with "/prod11" } { ...
- Chris_Olson
Nimbostratus
I'm getting close but have a question regarding using two redirects. We are set up with two virtual servers, same IP. One for 80, one for 443. I applied a generic redirect from http to https on the 80 server. - Deb_Allen_18Historic F5 AccountNo, you will need both iRules, one applied to each virtual server. The iRules should not interfere with each other, as they are applied to different virtuals and only one of the iRules will be triggered for any given connection. (Keeping in mind that a new connection to 2nd virtual will be established after redirection from first.) In general, you can't specify in one iRule the action that should be taken by another iRule for a different connection on a different virtual server.
- Deb_Allen_18Historic F5 AccountHi grimish -
if {(condition1) and (condition2)}{ pool admin_pool }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects