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=3&rev2=4 == Touch a File Method == - 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. + 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 [[https://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 [[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. @@ -61, +61 @@ == IfDefine Method == - 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. + 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/current/mod/core.html#ifdefine|IfDefine]] with a restart. {{{ <VirtualHost *:8080> @@ -109, +109 @@ ;; }}} + == Maintenance with Exceptions == + Sometimes it is advantageous to configure the server so that a few or even many IP address may bypass the maintenance page. Using the first example above as a template, we can create a [[https://httpd.apache.org/docs/current/rewrite/rewritemap.html|RewriteMap]] that allows individual IP addresses or even IP ranges to ignore the maintenance setting. This recipe can easily be extended to allows class A or B ranges as well. + + {{{ + <VirtualHost *:8080> + ServerName myfirstdomain.com + DocumentRoot "/var/www/htdocs" + + UseCanonicalName On + ErrorDocument 503 /maintenance/index.html + RewriteEngine on + RewriteMap exceptions /var/www/maintenance/exceptions.map + + # Allow Individual IP addresses past maintenance page + RewriteCond ${exceptions:%{REMOTE_ADDR}} =OK + RewriteRule ^ - [L] + + # Allow Class C ranges past maintenance page + RewriteCond %{REMOTE_ADDR} ^(\d+)\.(\d+)\.(\d+)\. + RewriteCond ${exceptions:%1.%2.%3} =OK + RewriteRule ^ - [L] + + # Redirect all request to a 503 return code when in maintenance mode + RewriteCond /var/www/maintenance/ALL -f [OR] + RewriteCond /var/www/maintenance/%{SERVER_NAME} -f + RewriteCond %{REQUEST_URI} !=/maintenance/index.html + RewriteRule ^ - [R=503,L] + + # Redirect away from the maintenance page if not in maintenance mode + RewriteCond /var/www/maintenance/ALL !-f + RewriteCond /var/www/maintenance/%{SERVER_NAME} !-f + RewriteRule ^/maintenance/index.html$ / [R,L] + </VirtualHost> + }}} + + Sample {{{exceptions.map}}} file + + {{{ + # Allow a single IP address through + 192.168.0.1 OK + # Allow a whole Class C through + 172.20.0 OK + }}} + --------------------------------------------------------------------- To unsubscribe, e-mail: docs-unsubscr...@httpd.apache.org For additional commands, e-mail: docs-h...@httpd.apache.org