Forum Discussion
wtwagon_99154
Apr 21, 2011Nimbostratus
Looking to direct users to a server based upon URI
I'm an iRules and coding rookie, but I am trying to complete the following:
User will try to hit:
http://www.x.com/httm_TTT.xml.gz
Where the TTT can be one of the following:
Server A: 111, 254, 115, 114, 860, 103
Server B: 101, 219, 104, 759, 102, 725
Server C: 107, C27, 119, C28, D01, 633
If the link is http://www.x.com/httm_111.xml.gz, send to server A
If the link is http://www.x.com/httm_219.xml.gz, send to server B
If the link is http://www.x.com/httm_107.xml.gz, send to server C
I figured the best way to accomplish this would be creating a class with those string values in it.
I created two string classes called qml01 and qml02 (third server isn' t available yet), and put the string in each (and nothing for value)
I then created an iRule to do the following:
when HTTP_REQUEST {
if { [matchclass [HTTP::uri] contains $..qml01] } {
log local
pool qml01.80
} elseif { [matchclass [HTTP::uri] contains $..qml02] } {
pool qml02.80
}
}
I was expecting the iRule to look at the class for a number, i.e. 111, and redirect to server one. However, I think I am off in my way of thinking a bit - as it didn't appear to work.
Log output is as follows:
TCL error: xxx Invalid matchclass operands - no class or list type found, this: string, rhs: $..qml01 (line 1) invoked from within "matchclass [HTTP::uri] contains $..qml01
Wanted to see if someone could point me in the right direction on completing my iRule. I appreciate the help.
- Joel_MosesNimbostratusSince you're not doing too many matches against the data, why not use switch instead?
This will switch pools based on the 3 characters in URIs that begin with "/httm_" while setting to the default pool for everything else.when HTTP_REQUEST { set default_pool [LB::server pool] if { [string tolower [HTTP::uri]] starts_with "/httm_" } { switch [string tolower [string range $test 6 8] ] { "111" - "254" - "115" - "114" - "860" - "103" { pool qml01.80 } "101" - "219" - "104" - "759" - "102" - "725" { pool qml02.80 } "107" - "c27" - "119" - "c28" - "d01" - "633" { pool qml03.80 } default { pool $default_pool } } } else { pool $default_pool } }
- wtwagon_99154NimbostratusThanks.
- wtwagon_99154NimbostratusThanks.
- hooleylistCirrostratusHi WT,
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