Forum Discussion

DaytonG_131489's avatar
DaytonG_131489
Icon for Nimbostratus rankNimbostratus
Oct 09, 2013

Serve maintenance page if file exists

We are hoping to let our developers control turning on maintenance pages for their sites. We were hoping that we could check for the existence of a file in (or outside) the application to determine whether or not to serve the maintenance page (served by the BIGIP).

 

We are hoping we can use an iRule to check for the existence of this file and if it exists, return the maintenance page and if it does not exist, continue processing.

 

I know that iControl can be leveraged to enable/disable iRules, but we were hoping for something that fits the above scenario. Has anyone done this?

 

Thanks!

 

4 Replies

  • This should be easy enough in BASH cronjob: curl get some status URI and enable or disable the iRule on the virtual servers, via tmsh as needed?

     

    I would not recommend doing this from whith the iRule itself, would be adding too much latency for each and every client request.

     

  • You could use an HTTP monitor and configure the 'Send String' to do an HTTP get on a file, /up.txt for example. Then configure 'Receive Disable String' with whatever you put in the up.txt file to indicate that the server should be marked down.

     

    For your maintenance page, you can specify a 'Fallback Host' in the HTTP profile you've associated with the virtual server. This is the page that users will be presented with in the event that no pool members attached to the virtual server are available.

     

  • Here's what Cory's description might look like:

     

    ltm monitor http http_file_exists_test {
        defaults-from http
        destination *:*
        interval 1
        recv 404\\sNot\\sFound
        recv-disable 200\\sOK
        send "GET /foo.php HTTP/1.1\\r\\nHost: server\\r\\n\\r\\n"
        time-until-up 0
        timeout 16
    }

    It's essentially the reverse of a normal monitor. Depending on how the web server responds to a file not found error (ie. 404 status code), the receive string would be the 404 response (doesn't exist so monitor is up), and receive disable string is the 200 OK (exists so monitor is down).

     

  • This definitely got us going in the right direction.

     

    We ended up creating an additional pool with a monitor that tests for the existence of the file. We then deployed an iRule that checked the status of that new pool to determine whether or not to display a maintenance page. This is probably less costly than doing a get with each request. We'll let the monitor take care of that.