Forum Discussion
breasoner_11658
Nimbostratus
Aug 16, 2010direct similar uris to their own pools via datagroup
Hi -
I have an iRule that was working just fine until I made a recent addition. The rule finds the uri and directs traffic to a pool based on the information contained in a datagroup:
when CLIENT_ACCEPTED {
set DATA_GROUP my_class
}
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
log local0.notice "Incoming Request: $uri"
set pool [class match -value $uri contains $DATA_GROUP]
if { $pool ne "" } {
log local0.notice "Directing to: $pool"
pool $pool
}
}
The datagroup looks like this:
clienta := Client-A-Pool
clientb := Client-B-Pool
The problem that I'm running into is we added a second site for clienta, in which the uri is clienta1. I added a line to the datagroup:
clienta1 := Client-A1-Pool
But it doesn't work. Anytime I go to http://mysite.com/clienta1, traffic gets directed to Client-A-Pool.
Anyone have any ideas on how I can make this work?
Thanks,
Brian.
7 Replies
- Chris_Miller
Altostratus
Since you're using "contains" instead of "equals," clienta1 matches the "clienta" datagroup line. - breasoner_11658
Nimbostratus
Thanks for the reply Chris.
I tried using 'equals' but the problem then became that anything after the uri wouldn't be matched and therefore wouldn't get directed to the pool.
For example:
http://mysite.com/clienta
http://mysite.com/clientaweb
http://mysite.com/clientaadmin
Should all go to the same pool.
http://mysite.com/clienta1
http://mysite.com/clienta1web
http://mysite.com/clienta1admin
Should go to a different pool. - Chris_Miller
Altostratus
Posted By breasoner on 08/16/2010 10:38 AM
Thanks for the reply Chris.
I tried using 'equals' but the problem then became that anything after the uri wouldn't be matched and therefore wouldn't get directed to the pool.
For example:
http://mysite.com/clienta
http://mysite.com/clientaweb
http://mysite.com/clientaadmin
Should all go to the same pool.
http://mysite.com/clienta1
http://mysite.com/clienta1web
http://mysite.com/clienta1admin
Should go to a different pool.
Good reason to use a different naming convention :-P I'm sure someone will have a good method to do this that allows you to look at the 6th character in the string and evaluate it...another option would be to put a1 higher in the datagroup list. - The_Bhattman
Nimbostratus
Hi Breasoner,
Have you looked into substr command?
Here is the WIKI link for this
http://devcentral.f5.com/wiki/default.aspx/iRules/substr.html
Bhattman - breasoner_11658
Nimbostratus
Thanks Bhatmann. I'll check it out today and post back with any findings/progress. - hoolio
Cirrostratus
I think the datagroup order is arbitrary, particularly after config reloads, so I'm not sure manually ordering them would be a long term solution. Also, I don't think the class functions return the most specific match for string searches. You could get the full class back as a TCL list using 'class get' and then iterate through the list looking for the longest match. Deb did something similar for 9.x in this example:
http://devcentral.f5.com/wiki/default.aspx/iRules/FindclassAgainstVariableLengthURI.html
Aaron - hoolio
Cirrostratus
dupe
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
