Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

IRULE Help

Qasim
Cirrostratus
Cirrostratus

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,

0 REPLIES 0