Forum Discussion

Jakub_Hornik_16's avatar
Jakub_Hornik_16
Icon for Nimbostratus rankNimbostratus
Jun 20, 2014

URi based redirection only if pool members are available.

Hello everyone. I am a newbie to iRules thus I apologize for any dumb questions in advance for foreseeable future. I have this iRule which does simple redirection based on URI:

when HTTP_REQUEST {

  if { [HTTP::host] equals "example.com" and ( [HTTP::uri] equals "/" or [HTTP::uri] equals "/example-client" or [HTTP::uri] equals "/example-client//" ) } {
           HTTP::redirect "https://example.com/example-client/login"
   }

This works fine as it should. However, developers now want to integrated a failover scenario where if two out of three server in the pool are not available, all requests will be forwarded to a third pool member which will only display simple error page. To solve this, I turned to priority groups. I put two 'production servers' in one PG and the error server to another PG. However, then I was informed that the 'error_page_server' cannot be modified to answer a request with any URI in it. How's that possible I do not know. Therefore, I would like to come up with modification to above iRule in following fashion: If productino servers are down, then strip any URI from incoming request before forwarding to 'error_page_request'. Otherwise, perform URI manipulation as usual.

So far, I found out that LB::status will be used. However, I cannot work out how to introduce that condition in the iRule.

I will be gratefull for any suggestions. Thank you very much. Best regards, JH.

12 Replies