Forum Discussion
Mike_S_59924
Nimbostratus
Apr 14, 2008comparison other than equals
Looks like irules only support equals and not equals. Is there any way to simulate greater than and less than.
The problem.
We have a web site w/ 240 virtual directories. We want to change to distributiong to 4 web servers. So essentially I want to say something like (in Englis)
for urils who start w/ anthying less than "Ko" goto web 1 else if it start w/ anyting less than "ME" goto web to, etc....
I really want to go to the 2nd letter so I can evenly distribute.
Thanks.
- hoolio
Cirrostratus
You should be able to do this with string compare (Click hereπ% set string1 abc abc % set string2 abd abd % string compare $string1 $string2 -1 % string compare $string2 $string1 1 % string compare $string1 $string1 0
- Mike_S_59924
Nimbostratus
Thanks Aaaron - Mike_S_59924
Nimbostratus
I just noticed the why question. - hoolio
Cirrostratus
Okay, I understand why you're trying to route requests to a specific server based on the requested URI. It might be easiest to create one pool per "application", create a string datagroup which has the URI tokens and the corresponding pool and then use a rule to look up the corresponding pool based on the requested URI. Having a pool per app allows you to use multiple servers to host an application and load balance between them. - Mike_S_59924
Nimbostratus
Hi Aaron. - hoolio
Cirrostratus
How about combining the two approaches so that you say paths starting with /?A-/?F go to pool 1, /?G-/?M to pool 2, /?N-/?T to pool 3 and /?U-/?Z to pool 4?when HTTP_REQUEST { Parse the third character in the path switch [string tolower [string range [HTTP::path]] 2 2] { a - b - c - d - e - f { pool pool_a_f } g - h - i - j - k - l - m { pool pool_g_m } n - o - p - q - r - s - t { pool pool_n_t } u - v - w - x - y - z { pool pool_u_z } default { Requested URI was less than three characters long pool pool_default } } }
- Mike_S_59924
Nimbostratus
Hi Aaron. - hoolio
Cirrostratus
Sorry, when first wrote the example, I was parsing the second character in the URI. I reread your initial post and saw that you wanted to parse the third character (second after the leading forward slash), so I updated the string range, but didn't update the comments. "Parse the second character in the path" should be third. - Mike_S_59924
Nimbostratus
Hi Aaron, - The error is that you have an opening brace before the switch argument (before the string tolower command). Remove that and the error should go away.
hen HTTP_REQUEST { Parse the fist character in the path switch -glob [HTTP::path] { "/[a-cA-C]*" { pool test1 } "/[d-lD-L]*" { pool test2 } "/[m-rM-R]*" { pool test3 } "/[s-zS-Z]*" { pool test4 } default { Requested URI was a leading forward slash only pool test5 } } }
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