Forum Discussion
pedinopa_170325
Nimbostratus
Mar 07, 2016iRule to select specific pool member
I am writing an irule to select a specific pool node based or the uri string.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/node1" { node 80 } "/node2" { node 80 } default { pool } } }
- amjadb_4287
Nimbostratus
So what's the question? is this what you are looking for: when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/node1" { pool node1_pool } "/node2" { pool node2_pool } default { pool default_pool } } } - pedinopa_170325
Nimbostratus
my question is I want to have 1 pool with many members and then the irule will switch (select) the appropriate member. I have followed the examples for using the switch command but haven't gotten it to work yet. when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "*/node1*" { pool member 80 } "*/node2*" { pool member 80 } } } - Greg_Labelle
Nimbostratus
I believe your problem is actually the "switch" command. That command does not accept wildcards for matching, you'll need to use a variable to pull the node number out of the uri before running your switch.
For example:
set node [substr [HTTP::uri] 0 "/"] switch node { "node1" { pool MyPool member Member1 80 } "node2" { pool MyPool member Member2 80 } default { pool MyPool } }
- pedinopa_170325
Nimbostratus
I got the irule to work using HTTP, now my challenge is getting it to work with HTTPS. Could I simply change the nodes in the pool to be 443 rather than 80 (assuming port 443 is bound to the server? when HTTP_REQUEST { switch -glob [HTTP::uri] { "/Store091" { node x.x.x.x 443 snat x.x.x.x 443 automap } "/Store092" { node y.y.y.y 443 snat y.y.y.y 443 automap } } }
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