IBM Support

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

Question & Answer


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 DocumentRoot directory. 
    For example /opt/IBM/HTTPServer/htdocs/
  2. Create the html file you wish to display when the back-end server is unavailable. 
    For example /opt/IBM/HTTPServer/htdocs/maintenance.html 
     
    <html>
    <head><title>Server Down For Maintenance</title>
    <body>
    <p>Site is currently down for maintenance.<br>Please try again later.</p>
    </body>
    </html>
  3. Edit the IBM HTTP Server configuration file (httpd.conf) and add one of the following stanzas, once per <virtualHost> and once to the bottom of httpd.conf
    1. # Return an HTTP 200 status with the custom maintenance.html
      RewriteEngine on
      RewriteCond %{DOCUMENT_ROOT}/serverdown.txt -f
      RewriteRule ^(.*)$ /maintenance.html [PT,E=skipwas:1]
    2. # Return an HTTP 503 status without customization
      RewriteEngine on
      RewriteCond %{DOCUMENT_ROOT}/serverdown.txt -f
      RewriteRule ^(.*)$ -  [PT,E=skipwas:1,R=503]
  4. To send both a customized message and a 503 HTTP status:
    1. Create /opt/IBM/HTTPServer/htdocs/maintenance.asis  using the following template:
      Status: 503 Service Unavailable
      Content-type: text/html
      
      <html>
      <head><title>Server Down For Maintenance</title>
      <body>
      <p>Site is currently down for maintenance.<br>Please try again later.</p>
      </body>
      </html>
    2. Append the following lines to httpd.conf:
      LoadModule asis_module modules/mod_asis.so
      AddHandler send-as-is asis
    3. Edit the IBM HTTP Server configuration file (httpd.conf) and add one of the following stanzas, once per <virtualHost> and once to the bottom of httpd.conf
      # Return an customized 503 response
      RewriteEngine on
      RewriteCond %{DOCUMENT_ROOT}/serverdown.txt -f
      RewriteRule ^(.*)$ /maintenance.asis  [PT,E=skipwas:]
  5. To restrict the URL's that return any of the preceding error pages, customize the first argument of the RewriteRule directive in the provided examples.
    For example, "^(/myapp.*)$"  to restrict to context root "myapp". 
    Any regular expression that matches against the path component of the URL can be used.
    To match against the query string or other parts of the fully qualified URL, consult the documentation for mod_rewrite.
  6. Restart IBM HTTP Server for these changes to take effect.
  7. Create  /opt/IBM/HTTPServer/htdocs/serverdown.txt to activate the maintenance page. Remove it to deactivate.

[{"Product":{"code":"SSEQTJ","label":"IBM HTTP Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Base Server","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.5;8.0;7.0","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
24 June 2020

UID

swg21397422