Forum Discussion

Parveez_70209's avatar
Parveez_70209
Icon for Nimbostratus rankNimbostratus
Mar 07, 2014

Maintenance Page Was Not Functioning Correctly : Sub-Pages Shows 404 Error

Hi,

 

We observed that the maintenance page was not functioning correctly with Sub-pages and showing 404 error.

 

Actual-URL: https://www.test.com/ URL With sub-URL: https://www.test.com/portal/welcome.htm : 404 error

 

Existing IRule:

 

======================

 

when CLIENT_ACCEPTED { if { [active_members [LB::server pool]] == 0 } {

 

pool maintenance_page

 

} }

 

=========================

 

Just to specify, that pool named mainenance_page consists of a member server, lets say: 10.10.10.10:80

 

Kindly guide.

 

Thanks and Regards Parveez

 

8 Replies

  • hi Parveez

    This would be because you don't rewrite the uri before sending it on to the fallback pool.

    Accessing "https://www.test.com/portal/welcome.htm" would make the user end up in ie "http://10.10.10.10/portal/welcome.htm".

    Try this instead:

    when CLIENT_ACCEPTED { 
        if { [active_members [LB::server pool]] == 0 } {
    
            HTTP::uri "/default.html"
            pool maintenance_page
    
        }
    }
    

    Or this one (if your maintenance page has images and they're located in ie /img):

    when CLIENT_ACCEPTED { 
        if { [active_members [LB::server pool]] == 0 } {
            set uri [string tolower[HTTP::uri]]    
    
            if { not ($uri equals "/default.html" or $uri starts_with "/img/") } {
                HTTP::uri "/default.html"
            }
            pool maintenance_page
        }
    }
    

    Good luck!

    /Patrik

  • Hi Patrick,

     

    Thank you so much, but a quick query, will the below work ?

     

    when HTTP_REQUEST { if { [HTTP::uri] starts_with "/" } { node 10.10.10.10 80 } else { pool maintenance_page } }

     

    10.10.10.10 is a member server of the pool:mainenance_page

     

    Thanks and Regards

     

  • Hi Parveez!

    Reformatting the rule to make it readable. 🙂

    when HTTP_REQUEST { 
        if { [HTTP::uri] starts_with "/" } { 
            node 10.10.10.10 80
        } else { 
            pool maintenance_page
        }
    }
    

    This rule would send all users for all requests that starts with "/" to node 10.10.10.10:80. Problem is that it would do so, no matter the state of the pool members and for all request (ie, website.com/PROD" start with "/" and so does "website.com/"). I don't believe there even is such a thing as a uri that does not start with "/".

    The maintenance pool would never be used because the condition before it would always be true.

    /Patrik

  • Hi Patrick,

     

    So, how can we reformat the Irule incase if its necessary,lets say match everything with "/" instead of /default.html , to go to pool: maintenance page , based on the irule which I shared as an example.

     

    Kindly guide.

     

    Thanks and Regards Parveez

     

  • And Hi Patrick,

     

    Both the Irules suggested by you got error in F5 EDITOR, can you cross-check that please.

     

    Thanks and Regards Parveez

     

  • Hi!

    Yeah, there was a space missing on the second rule and I forgot to change the event you initially posted. 🙂

    Here are the revised rules. They should work:

    when HTTP_REQUEST { 
        if { [active_members [LB::server pool]] == 0 } {
    
            HTTP::uri "/default.html"
            pool maintenance_page
    
        }
    }
    
    when HTTP_REQUEST { 
        if { [active_members [LB::server pool]] == 0 } {
            set uri [string tolower [HTTP::uri]]    
    
            if { not ($uri equals "/default.html" or $uri starts_with "/img/") } {
                HTTP::uri "/default.html"
            }
            pool maintenance_page
        }
    }
    

    Question: What do you actually want to achieve with the rule? Do you want a rule that you can activate manually during a maintenace window or do you want one that automatically shows information to customers if all pool members are down?

    The latter can also be achieved by the fallback host in the http profile, however, not as pretty as URI rewriting since customers would get redirected and can't hit refresh to stay on the same page they were on before the pool failure.

    Good luck!

    Kind regards, Patrik

  • Hi Patrik,

     

    Thank you, both are valid syntax now. But the issue is,while attaching http profile into the Virtual-server , the page is broken up, so not planning to attach HTTP Profile, so above suggested Irule, which are basically HTTP_REQUEST Irule may fail to attach.

     

    How the same we can attach/convert to CLIENT_ACCEPTED.

     

    And coming back to your query: yes we want to attach the Irule manually at the time of Maintenance activity.

     

    Thanks and Regards Parveez

     

  • Hi Parveez

    Without an HTTP profile you can't access layer 7, which means that manipulation of ie. uri and host is impossible in the load balancer.

    In your case I would firstly attempt to find, and solve the problem in regards to the HTTP profiles (because you lose so much functionality in the F5 without it, ie caching, compression and layer 7 manipulations) or consider using some server-side manipulation, (apache or IIS rewrites) to serve the maintenance page no matter what URI is used (or trigger a redirect to the maintenance page).

    With server side rewrites your original iRule should work:

    when CLIENT_ACCEPTED { 
        if { [active_members [LB::server pool]] == 0 } {
    
            pool maintenance_page
    
        }
    }
    

    Good luck!

    /Patrik