IBM Support

Configuring a temporary 'Site Down For Maintenance' page in IBM HTTP Server

Technote (FAQ)


Question

When IBM HTTP Server is used to front-end a WebSphere Application Server deployment, there might be a need to temporarily redirect users to a 'Site Down For Maintenance' page when one or more back-end Application Servers require off-line maintenance.

Answer

The following example outlines one method for accomplishing this:

  1. Review the IBM HTTP Server configuration file (httpd.conf) to determine IBM HTTP Server's document root directory. Example:

    DocumentRoot "C:/Program Files/IBM/HTTPServer/htdocs"

  2. Create the html file you wish to display when the back-end server is unavailable. Example:

    <html>
    <head><title>Server Down For Maintenance</title>
    <body>
    <p>&nbsp;</p>

    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div align="center"><span style="font-family:Times New Roman, Times, serif; font-weight:bold;color:#990000; font-size:30px;">
    Site is currently down for maintenance.<br>Please try again later.
    </span>
    </div></td></tr>
    </table>
    </body>
    </html>

    Then place this file in the Document root directory. Example:

    C:\Program Files\IBM\HTTPServer\htdocs\maintenance.html

  3. Create an empty text file and place this in the Document root directory as well. Example:

    C:\Program Files\IBM\HTTPServer\htdocs\serverdown.txt

  4. Edit the IBM HTTP Server configuration file (httpd.conf) and add the following lines, making sure to adjust file names if needed:

    • To redirect ALL requests to the maintenance page with a 200 status code:

      LoadModule rewrite_module modules/mod_rewrite.so
      RewriteEngine on
      RewriteCond %{DOCUMENT_ROOT}/serverdown.txt -f
      RewriteRule ^(.*)$ /maintenance.html [PT]

    • To redirect only application specific requests to the maintenance page with a 200 status code. (In this example, /myapp represents the context root of the application):

      LoadModule rewrite_module modules/mod_rewrite.so
      RewriteEngine on
      RewriteCond %{DOCUMENT_ROOT}/serverdown.txt -f
      RewriteRule ^(/myapp.*)$ /maintenance.html [PT]

    • To redirect ALL requests to the maintenance page with a 503 status code (IBM HTTP Server 6.x):

      LoadModule asis_module modules/mod_asis.so
      AddHandler send-as-is asis
      LoadModule rewrite_module modules/mod_rewrite.so
      RewriteEngine on

      RewriteCond %{DOCUMENT_ROOT}/serverdown.txt -f
      RewriteRule ^(.*)$ /maintenance.asis [PT]

      Where the html file created in step 2 has been renamed maintenance.asis and contains the following headers preceding the <html> content:

      Status: 503 Service Unavailable
      Content-type: text/html

      Example:

      Status: 503 Service Unavailable
      Content-type: text/html

      <html>
      <head><title>Server Down For Maintenance</title>
      <body>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div align="center"><span style="font-family:Times New Roman, Times, serif; font-weight:bold;color:#990000; font-size:30px;">
      Site is currently down for maintenance.<br>Please try again later.
      </span>
      </div></td></tr>
      </table>
      </body>
      </html>

    • To redirect ALL requests to the maintenance page with a 503 status code (IBM HTTP Server 7.x and later):

      LoadModule rewrite_module modules/mod_rewrite.so
      RewriteEngine on
      RewriteCond %{DOCUMENT_ROOT}/serverdown.txt -f
      RewriteCond %{REQUEST_URI} !^(/maintenance.html)$
      RewriteRule ^(.*)$ - [R=503]
      ErrorDocument 503 /maintenance.html

  5. Restart IBM HTTP Server for these changes to take effect.

Result:
  • When 'serverdown.txt' is present in the Document root directory, IBM HTTP Server will redirect all (or application specific) requests to /maintenance.html.

  • When 'serverdown.txt' is not present in the Document root directory, IBM HTTP Server will route all requests normally.

Document information

More support for: IBM HTTP Server
Base Server

Software version: 6.0, 6.1, 7.0, 8.0, 8.5

Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

Reference #: 1397422

Modified date: 31 October 2009


Translate this page: