Forum Discussion
CraigM_17826
Altocumulus
Dec 21, 2009switch command
Hi all,
[Update: fixed the redirect issues so I've removed the examples from the thread. It was just my dyslexic typing]
I'm trying to clean up and optimise some of my iRules. Currently I have quite a large block of if blocks for pool selections. The basic form follows
if { [[string tolower [HTTP::uri]] contains "sometext" }{
pool "pool-name"
return
}
This all works. I have now tried the follwoing switch commands for the above cases
switch -glob [string tolower [HTTP::uri]] {
"sometext" {pool pool-name}
"sometext" {pool pool-name2}
}
What happens though is that the pool commands dont seem to work, I just get an error back from the webserver on the default pool saying the directory (as supplied by "sometext" does not exist.
I have tried with and without the -glob option and it doesn't seem to make a difference. I have run out of ideas at the moment. Any suggestions welcome.
Regards
Craig
2 Replies
- The_Bhattman
Nimbostratus
Hi Craig,
Seems like the irule is working in that it see's sometext in the URI and sends into the pool, but the webserver in the pool complaining there is no director for the content. Have you tried pointing directly to the webserver (bypassing the load balancer) to see if the problem is not on the its end?
Bhattman - CraigM_17826
Altocumulus
Hi Bhattman,
thanks for the reply. Actually I rejigged the rule slightly and put in some log statements to see what was going on. It goes somthing like this
switch -glob [string tolower [HTTP::uri]] {
"/sometext" {
log "Using pool1 for URI [HTTP::uri]"
pool pool1
}
"/sometext2" {
log "Using pool2 for URI [HTTP::uri]"
pool pool2
}
}
log local0. "URI: [HTTP::uri]"
What I noticed was that the cases were not matching yet the last log statement was inidcating the specified URI should have matched. For example if I entered http://webserv.com/sometext the switch would not match byt the log statement would indicate the URI was in fact /sometext. The same applied to all the cases in the switch statement, they all failed yet the log statement indicated they should have matched.
Craig
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
