httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Httpd Wiki] Update of "MaintenancePage" by SeanTimmins
Date Wed, 22 Jun 2016 16:18:51 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.

The "MaintenancePage" page has been changed by SeanTimmins:
https://wiki.apache.org/httpd/MaintenancePage?action=diff&rev1=2&rev2=3

  = Recipes for Implementing a Maintenance Page =
  
- It is relatively common for Apache httpd users to wish to serve a standard page while underlying
software deployments are occurring or even if the site is down temporarily for whatever reason.
Below are details some of the methods by which this can be achieved. All recipes share in
common that you redirect to a page served with a 503 return code to prevent search engines
indexing the maintenance page.
+ It is relatively common for Apache httpd users to wish to serve a standard page while underlying
software deployments are occurring, or even if the site is down temporarily. Below are details
on some of the methods by which this can be achieved. All recipes share in common the idea
that you redirect to a page served with a 503 return code to prevent search engines indexing
the maintenance page.
  
  == Touch a File Method ==
  
- This recipe is good in that it can almost trivially be programmed in a shell script or similar.
Maintenance is enabled by 'touching' a single file on the file system and disabled by removing
that file. In this example a generic piece of Apache configuration allows either individual
virtual hosts to be put into maintenance mode, or the whole servers. In practice, especially
with a  large number of virtual host, the maintenance configuration could be split out into
an [[https://httpd.apache.org/docs/current/mod/core.html#include|Include]] file.
+ This recipe is good because it can be simply programmed in a shell script or similar. Maintenance
is enabled by 'touching' a single file on the file system and disabled by removing that file.
In this example a generic piece of Apache configuration allows either individual virtual hosts
to be put into maintenance mode, or the whole server. In practice, especially with a large
number of virtual host, the maintenance configuration could be split out into an [[https://httpd.apache.org/docs/current/mod/core.html#include|Include]]
file, or moved to the global [[http://httpd.apache.org/docs/current/mod/directive-dict.html#Context|context]],
although in this case you may need to set {{{RewriteOptions InheritBefore}}} in each virtual
host.
  
- What is not included below is the configuration to enable the serving of the URI {{{/maintenance/index.html}}}
itself as a page.
+ What is not included below is the [[https://httpd.apache.org/docs/current/mod/core.html#directory|Directory]]
configuration to enable the serving of the URI {{{/maintenance/index.html}}} itself as a page.
+ 
+ Also please note, if a virtual host is accessed using any [[https://httpd.apache.org/docs/current/mod/core.html#serveralias|ServerAlias]]
then you need to add {{{UseCanonicalName On}}} to the configuration, otherwise only people
using the actual [[https://httpd.apache.org/docs/current/mod/core.html#servername|ServerName]]
for a particular virtual host will get the maintenance page. If, for whatever reason, you
cannot use this directive, then an appropriate filename can be substituted for {{{%{SERVER_NAME}}}}
in the relevant [[https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond|RewriteCond]]
in each virtual host.
  
  {{{
  <VirtualHost *:8080>
@@ -48, +50 @@

  </VirtualHost>
  }}}
  
- The downside to this recipe is that it incurs file system checks for all requests hitting
your web server, so careful testing is required.
+ The downside to this recipe is that it incurs file system checks for all requests hitting
your web server, so careful performance testing is required. With this configuration you may
then perform the following operations.
+ 
+ {{{
+ # Enable maintenance mode for all virtual hosts
+ touch /var/www/maintenance/ALL
+ # Enable maintenance mode for a single virtual host
+ touch /var/www/maintenance/myseconddomain.com
+ }}}
  
  == IfDefine Method ==
  
- This recipe requires that you modify apachectl to cope with 'enabling/disabling' maintenance.
The downside is that it requires a full stop/start since you cannot pass a directive that
is interpreted by [[https://httpd.apache.org/docs/2.2/mod/core.html#ifdefine|IfDefine]] with
a restart.
+ This recipe requires that you modify {{{apachectl}}} to cope with 'enabling/disabling' maintenance.
The upside is that there are no file system checks, the downside is that it requires a full
stop/start since you cannot pass a name that is interpreted by [[https://httpd.apache.org/docs/2.2/mod/core.html#ifdefine|IfDefine]]
with a restart.
  
  {{{
  <VirtualHost *:8080>
@@ -94, +103 @@

  
  {{{
  maintenance)
-     $HTTPD -k stop
+     $HTTPD -k graceful-stop
      sleep 3
      $HTTPD -D Maintenance -k start
      ;;

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Mime
View raw message