Forum Discussion

pedinopa_170325's avatar
pedinopa_170325
Icon for Nimbostratus rankNimbostratus
Mar 07, 2016

iRule 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 } } }

 

4 Replies

  • 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 } } }
  • 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 } } }
  • 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
     }
    }
    
    
  • 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 } } }