Forum Discussion
Brian_Kenworthy
Nimbostratus
Jul 31, 2009Rule Modification Help with Switch
Hi all, I have the following existing rule that we will be adding another pool to. I am using the switch command, but am wondering if I need to add some if/else clauses. Here's the existing rule:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/xml/order.asp*" -
"/xml/status.asp*" -
"/vmsxml/order.asp*" -
"/vmsxml/status.asp*" -
"/_xmlbeta/status_mismo21.asp*" -
"/_xmlbeta/status.asp*" -
"/_xmlbeta/rels_status_mismo21.asp*" -
"/vendor/status.asp*" {
host.mydomain.com_B2B_HTTPS
}
default {
host.mydomain.com_GUI_HTTPS
}
}
}
We are adding a new URI to the existing URL which will forward the traffic to the new pool:
"/BatchProcessing*" -
host.mydomain.com_BatchPro_HTTPS
I'm not quite sure how to add this with the switch command...do I need to use an if/else clause in my rule, or can I add another switch command? You help is much appreciated!
Thanks in advance,
Brian
- Just added it before the "default" case.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/xml/order.asp*" - "/xml/status.asp*" - "/vmsxml/order.asp*" - "/vmsxml/status.asp*" - "/_xmlbeta/status_mismo21.asp*" - "/_xmlbeta/status.asp*" - "/_xmlbeta/rels_status_mismo21.asp*" - "/vendor/status.asp*" { pool host.mydomain.com_B2B_HTTPS } "/BatchProcessing*" { pool host.mydomain.com_BatchPro_HTTPS } default { pool host.mydomain.com_GUI_HTTPS } } }
- Brian_Kenworthy
Nimbostratus
Hi Joe, I did omit the "pool" from the original post, but am I missing a "-" somewhere? I am getting a 404 after modifying the rule now, but not seeing anything in my weblogs. Here's the exact syntax I am using on the rule: - The only thing I can see is that you are doing a "string tolower" on your URI but comparing it to "/BPro*" which is not lower case. That was my bad for not noticing that in the previous post. First thing I would do would be to replace "/BPro*" with "/bpro*". If that doesn't work, you'll need to do some logging to look at the inbound URI's and then where they are getting matched. This can be done with something like this:
when HTTP_REQUEST { log local0. "Request for URI [string tolower [HTTP::uri]]" switch -glob [string tolower [HTTP::uri]] { "/clientmismo/order.asp*" - "/vendormismo2/status.asp*" - "/vmsxml/order.asp*" - "/vmsxml/status.asp*" - "/_xmlbeta/ors/status_mismo21.asp*" - "/_xmlbeta/ors/status.asp*" - "/_xmlbeta/ors/rels_status_mismo21.asp*" - "/vendornla/status.asp*" { log local0. "Matched first case" pool beta3.res-direct.com_B2B_HTTPS } "/bpro*" { log local0. "Matched /bpro*" pool beta3.res-direct.com_BatchPro_HTTPS } default { log local0. "Match not found, defaulting to beta3.res-direct.com_GUI_HTTPS pool" pool beta3.res-direct.com_GUI_HTTPS } } }
- Brian_Kenworthy
Nimbostratus
Yep, that was it...forgot that we lower the string so that the client can use any case. Not sure how I missed that either. Thanks again, it's working like a charm.
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