Forum Discussion

Brian_Ott_11267's avatar
Brian_Ott_11267
Icon for Nimbostratus rankNimbostratus
Dec 07, 2004

Redirecting to the same pool, different node

Is there a builtin variable that stores the pool the request is going to?

 

 

I need to redirect the request to another node in the same pool. But I don't know how to have it do that, exactly.

 

 

I would want to make sure the request was sent to a new node in the pool, and not the same one.

 

 

Is it possible?

 

 

Also is it possible to store information in a variable and still have it availiable when the iRule is called again?

 

 

For example, if all of the nodes for some reason report as busy(they should never do that unless they are down, but I want to avoid a loop), it doesn't bother with the request anymore and redirects to an unavailable page on another server?

 

 

Hopefully this makes sense.

 

 

-Brian.
  • drteeth_127330's avatar
    drteeth_127330
    Historic F5 Account
    The command
    LB::server pool
    returns the name of the selected pool. The command
    LB::server addr
    returns the address of the selected pool member.

    I recommend a different approach to what I think you are trying to accomplish. Rather than avoid the same node when redirecting, why not just add a limit of no more than n redirects? It is unlikely that your LB mode will choose the same node n times in a row, and if the failure is more than intermittent, the service checks should mark the node down. Here is a rule that redirects up to 4 times when a server error occurs:

     
     when HTTP_REQUEST { 
         set http_path [HTTP::path] 
         set http_query [HTTP::query] 
     } 
     when HTTP_RESPONSE { 
         if {([HTTP::status] >= 500) && ([string length $http_query] < 3)} { 
             HTTP::redirect "${http_path}?${http_query}x" 
         } 
     } 
     

    Finally, in order to redirect to an unavailable page when all the pool members are down, you should configure a fallback host with the fallback http profile option.
  • drteeth_127330's avatar
    drteeth_127330
    Historic F5 Account
    I should have pointed out that I'm playing games with the querystring parameters in order to keep the redirect count. If your page actually contains form fields, then you need to take care to use a unique name and search the querystring for it. Additionally, you'll need to add an equal sign after the name. But I think this demonstrates the basic idea.