Forum Discussion

mop10011_63574's avatar
mop10011_63574
Icon for Nimbostratus rankNimbostratus
Mar 08, 2009

how to rewrite fallback page

Say I have these pools on my F5 ltm:

 

poolone, pooltwo, poolthree

 

 

The dns to get to each of these respectively is:

 

www.one.com

 

www.two.com

 

www.three.com

 

 

All three pools use the same Profile named "maintenance". The maintenanace profile has a Fallback Host of http://www.four.com/notices/maintenance.html.

 

 

When the user is directed to the fallback host, is there any way on the F5 to rewrite the url the user sees in the address bar, such that instead of seeing:

 

"http://www.four.com/notices/maintenance.html"

 

 

the user would see one of these:

 

"http://www.one.com/notices/maintenance.html"

 

"http://www.two.com/notices/maintenance.html"

 

"http://www.three.com/notices/maintenance.html"

 

 

Thanks, Mark

 

5 Replies

  • Hi Mark,

    You can configure the fallback host on a single connection using the HTTP::fallback command (Click here).

     
     when HTTP_REQUEST { 
      
         Set the fallback host based on the requested host. 
        HTTP::fallback "http://[HTTP::host]/notices/maintenance.html" 
     } 
     

    Aaron
  • Thanks Aaron and Denny. You are correct Denny, I want the browser to display a different URL than what I'm directing them to. It's a little confusing when a user attempts to go to www,one.com, it's down, and they are directed to www.four.com for the maintenance notice.

     

     

    Mark
  • I think I missed the original point then. If you want to transparently rewrite requests so that the client gets "maintenance page" content when the default pool of the VIP is down, you can use a rule like this (Click here😞

     
       when RULE_INIT {   
      
           Use a prefix for the path that does not already exist in the application 
          set ::maintenance_prefix "/maintenance/" 
      
           The default maintenance page 
          set ::maintenance_page "maintenance.html" 
       }   
       when CLIENT_ACCEPTED {   
      
           Save the name of the default pool on the VIP 
          set default_pool [LB::server pool] 
       }   
       when HTTP_REQUEST {   
      
           Check if there aren't any active members in the default pool 
          if { [active_members $default_pool] < 1 } {  
      
              Primary members are unavailable.  Check if the URI has not already been rewritten. 
             if {not ([HTTP::path] starts_with $::maintenance_prefix)}{   
      
                 Rewrite the URI to the maintenance prefix/maintenance page (/maintenance/maintenance.html)   
                HTTP::uri "$::maintenance_prefix$::maintenance_page" 
             }   
              Use the maintenance pool 
             pool maintenance_pool  
      
          } else {  
      
              Use the VIP's default pool 
             pool $default_pool  
          }  
       } 
     

    Aaron
  • Note: As the client is not being redirected, you would want to set the maintenance pool members to set appropriate caching headers to prevent the client from caching the maintenance content. This would ensure that the client (or an intermediate proxy) does not cache the maintenance content for the production URIs.

     

     

    Aaron