For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Qasim's avatar
Qasim
Icon for Cirrostratus rankCirrostratus
Aug 06, 2020

IRULE Help

Hi,

 

I have been using the following Irule for some services but wondering if someone could help me update this so I can use the same FQDN but it routes the traffic to the right pool by looking at the URL path:

 

Here is the current rule:

proc checkPoolStatus {poolName} {

  if {[active_members $poolName] > 0} {

    pool $poolName    

  } else {

    HTTP::respond 503 content "Service Unavailable"

  }

}

 

when HTTP_REQUEST {

 

  # list of all pools

  set poolList "efg_pool abc_POOL"

 

  # switch to check pool stats proc and increment PoolsDown counter if necessary

  switch -glob [HTTP::host] {

    "test.host.com" {

      set poolsDown 0

      foreach pool $poolList {

        if {[active_members $pool] < 1} {

          incr poolsDown

        }

      }

   if {$poolsDown > 0} {

    HTTP::respond 503 content "ERROR"

   } else {

      HTTP::respond 200 content "OK"

   }

    }

      "abc.test.com" {call checkPoolStatus "abc_pool"}

      "efg.test.com" {call checkPoolStatus "efg_pool"}

  }

}

 

the above IRULE has a health monitor that goes on GTM.

 

kind regards,

No RepliesBe the first to reply