Forum Discussion

Mr_K_63985's avatar
Mr_K_63985
Icon for Nimbostratus rankNimbostratus
Feb 18, 2010

Fallback Host - Keep VIP URL

What I am hoping to achieve is to have fallback host continue to use the VIP URL.

 

 

For example:

 

www.mysite.com

 

pool:web1.mysite.com, web2.mysite.com

 

fallback host:web-static.mysite.com

 

 

If web1/2 is down, www.mysite.com gets redirected to web-static.mysite.com. However I would like to keep the URL as www.mysite.com instead of web-static. Is this doable via iRule?

3 Replies

  • Sure...

     
     when HTTP_REQUEST { 
      
         Save the URI 
        set uri [HTTP::uri] 
     } 
     when LB_FAILED { 
      
        HTTP::fallback "http://web-static.mysite.com$uri" 
     } 
     

    Aaron
  • I tried your iRule, however when I take down the web server, it still shows fallback host's URL, instead of VIP URL.
  • If you send a redirect to the client, the address bar will update with the new location. If you define the web-static.mysite.com server in a pool, you could check if the main www.mysite.com pool is down in CLIENT_ACCEPTED and select the web-static pool instead:

      
      when CLIENT_ACCEPTED {  
        
          Check if the VIP's default pool has no members up  
         if {[active_members [LB::server pool]] == 0}{  
        
             Select alternate pool  
            pool www-static.mysite.com_pool  
         }  
      }  
      

    This will only check the pool state of the VIP's default pool when each client connects to the VIP. If you want to check on each HTTP -request you could move the pool checking to HTTP_REQUEST:

      
      when CLIENT_ACCEPTED {  
        
          Save the name of the VIP's default pool 
         set default_pool [LB::server pool]  
      }  
      when HTTP_REQUEST {  
        
          Check if the VIP's default pool has no members up  
         if {[active_members $default_pool] == 0}{  
        
             Select alternate pool  
            pool www-static.mysite.com_pool  
         }  
      }  
      

    If you wanted to trigger this same logic when an individual load balancing attempt fails, you could add logic to the LB_FAILED event which checks 'if {[active_members $default_pool] == 0' and then calls LB::reselect to select www-static.mysite.com_pool. See the LB::reselect wiki page for details:

    LB::reselect

    http://devcentral.f5.com/wiki/default.aspx/iRules/lb__reselect

    Aaron