Forum Discussion

AngryCat_52750's avatar
AngryCat_52750
Icon for Nimbostratus rankNimbostratus
Feb 13, 2015

irule for port listener - pool redirect

guys/gals -

we have two servers that listen for http requests on multiple ports (5010/5020/5030/5040). Instead of multiple VS with the various port listeners can i just have irule with a VS listening on any?

would the TCP::local_port work with HTTP_REQUEST?

 when HTTP_REQUEST {
    switch -glob [TCP::local_port] {
        "5010" { pool pool_5010 }
        "5020" { pool pool_5020 }
        "5030" { pool pool_5030 }
        "5040" { pool pool_5040 }
        default { discard }
    }
}

Thoughts ideas??

4 Replies

  • THi's avatar
    THi
    Icon for Nimbostratus rankNimbostratus

    If the pools are similar (e.g. same application listening to multiple ports/multiple app instances on each server), you may even use one pool with port any. And either use iRule or ACLs (even AFM or external FW) to restrict the ports to those you need. As normal with using port any, the port translation is disabled at the VS. Pay attention to persistence and monitors as there will be only one pool with two members in this case.

     

    I had a case where there were 20+ ports and the customer had created a lot of front end and backend VSes and pools, one set for each port. Using wildcard VSes and pools the config was reduced 20+ fold..

     

  • Thanks for the comments THi - I ended up creating multiple pools to setup individual monitors and for the VS, i set it up as an any listener and applied the iRule below to move traffic..

    when CLIENT_ACCEPTED {
            switch - glob [TCP::local_port] {
                            "5010" { pool pool_5010 }
                            "5020" { pool pool_5020 }
                            "5030" { pool pool_5030 }
                            "5040" { pool pool_5040 }
                            default { discard }
            }
    }
    
    • THi's avatar
      THi
      Icon for Nimbostratus rankNimbostratus
      That's ok, in my case the customer was ok with one pool with port any. Major problem was the config size getting somewhat unmanageable as they were expecting to have even more ports in the future. Sacrifice was on the monitoring of individual ports.
  • Hi kulastone,

    no need to "-glob" (it will save you CPU cycles) and no need to put port numbers into quotes.

    I don´t have access to a LTM right now. But this one may work as well:

    when CLIENT_ACCEPTED {
         if {(([TCP::local_port] == 5010) ||
              ([TCP::local_port] == 5020) ||
              ([TCP::local_port] == 5030) ||
              ([TCP::local_port] == 5040))} {
            pool pool_[TCP::local_port]
         } else {
              discard
         }
    }
    

    Thanks, Stephan