Forum Discussion

wixxyl_98682's avatar
wixxyl_98682
Icon for Nimbostratus rankNimbostratus
Jul 11, 2013

Routing to individual pool member based on URI

Dev,

Looking to route to several backend ports on a server based on URI. My thoughts are creating one pool that references the server's four different ports, 8081-8084, and using a switch statement to route to the server's instances for each request. Something similar to the below statement is what I'm needing. I've tested the iRule, and it seems to be hitting the default pool, but not going to any of the other instances. I've tried */wfbild*, /wfbild* in the rule, but to no avail. Anything I'm missing in the rule? Also, I am SNAT'ing these, do I need to call that out in this rule or does the rule get processed and then the VS does it's own conditions after that? I took off persistence on this VIP as well so I don't think there's anything happening there. Any help would be greatly appreciated.

when HTTP_REQUEST {
  switch [string tolower [HTTP::uri]] {
      "/wfdevl" {
        pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8081
      }
      "/wfbild" {
        pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8082
      }
       "/wftest" {
        pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8083
      }
       "/wftrng" {
        pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8084
      }
       default {
        pool  sis-ssb-devl.dev.uga.edu_Pool
      }
   }
}

2 Replies

  • I've tried */wfbild*, /wfbild* in the rule, but to no avail.have you added -glob in switch?

     

     

    iRules 101 - 04 - Switch by Joe Pruitt

     

    https://devcentral.f5.com/tech-tips/articles/irules-101-04-switch

     

     

    My thoughts are creating one pool that references the server's four different portsyou can use "node" command instead of pool. for node command, you do not need to define pool.

     

     

    node

     

    https://devcentral.f5.com/wiki/iRules.node.ashx

     

  • Thanks Nitass, that was what I was needing. My finished rule ended up looking like this, in case anybody needs something similar in the future.

     when HTTP_REQUEST {
      switch -glob [HTTP::uri]] {
          "*/wfdevl*" {
            pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8081
          }
          "*/wfbild*" {
            pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8082
          }
           "*/wftest*" {
            pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8083
          }
           "*/wftrng*" {
            pool sis-workflow-dev.dev.uga.edu member 172.17.140.14:8084
          }
           default {
            drop
            log local0. "connection dropped from [IP::client_addr]"
          }
       }
    }