Forum Discussion

Joseph_Lindsly's avatar
Nov 03, 2014

iRule to redirect traffic between 2 pools based on the URI

I currently have a VIP and pool created for a customer. They are planning to move some services to a new server farm.

They can't create a new URL for this new server farm.

They have requested that i create an irule to redirect traffic between the old server farm (pool1) and the new server farm (pool2) based off of the URI.

For example, if a user types www.abc.com/123, it needs to go to pool1 and if a user types www.abc.com/xyz, it needs to go to pool2. I have created the new pool, but i can't get the irule to work.

This is what i have so far.

when HTTP_REQUEST {
  if { [HTTP::uri] ends_with "123*" } {
     pool pool1
  } elseif { [HTTP::uri] starts_with "/xyz" } {
     pool pool2
 }
}

4 Replies

  • Hi Joseph,

    Something may be wrong on your first condition.

    Why do you need ends_with and a wildcard at the end of the condition ?

    This should work as a replacement :

    when HTTP_REQUEST {
      if { [HTTP::uri] starts_with "/123" } {
         pool pool1
      } elseif { [HTTP::uri] starts_with "/xyz" } {
         pool pool2
     }
    }
    
    • mrp_235984's avatar
      mrp_235984
      Icon for Nimbostratus rankNimbostratus

      Can we do it in the same pool but different port number?

       

  • Hi Joseph,

    Something may be wrong on your first condition.

    Why do you need ends_with and a wildcard at the end of the condition ?

    This should work as a replacement :

    when HTTP_REQUEST {
      if { [HTTP::uri] starts_with "/123" } {
         pool pool1
      } elseif { [HTTP::uri] starts_with "/xyz" } {
         pool pool2
     }
    }
    
    • mrp_235984's avatar
      mrp_235984
      Icon for Nimbostratus rankNimbostratus

      Can we do it in the same pool but different port number?