Redirect to pool and remove path

Hi

Hi

I written a rule that checks if members of a pool are down, and if so direct to a pool with a server that is hosting a holding page.

If not, and the members are up, it goes to the original pool. This has worked in testing:

when HTTP_REQUEST {
if {[active_members POOL_LIVEPOOL] == 0} {
pool HOLDING_POOL
} else {
pool POOL_LIVEPOOL }
}

However I found that if the members are down and someone doesn’t just request the main page, but puts a pth on the end, then we get a 404 from the server with the holding page. I need to strip the path off the end of any request so tht all requests are delivered to the holding pool as a root request.

I have tried to do a string map from another irule where this works but it doesn’t work here.

when HTTP_REQUEST {
if {[active_members POOL_LIVEPOOL] == 0} {
HTTP::path [string map { /* / } [HTTP::path]]
pool HOLDING_POOL
} else {
pool POOL_LIVEPOOL }
}

Can anyone give me a pointer as to what I should do to strip the path from a request when the “if” condition is met??

Many thanks

DJC

HTTP::path [string map { /* / } [HTTP::path]]

you cannot do that because it will change all the path of maintenance page objects such as image, css, etc.

you may try something like this.

e.g.

[root@ve11a:Active:In Sync] config  tmsh list ltm rule qux
ltm rule qux {
    when HTTP_REQUEST {
  if { [active_members [LB::server pool]] < 1 } {
    switch [HTTP::path] {
      "/f5.gif" {
        pool maint
      }
      default {
        HTTP::uri /
        pool maint
      }
    }
  }
}
}