Skip to content

Instantly share code, notes, and snippets.

@hasmukhrathod
Last active July 10, 2017 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasmukhrathod/a1fe6e0bd081b2b32c5f706010ca6abb to your computer and use it in GitHub Desktop.
Save hasmukhrathod/a1fe6e0bd081b2b32c5f706010ca6abb to your computer and use it in GitHub Desktop.
Maintenance Mode on-off
/etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName ELB/DNS
RackEnv production
DocumentRoot /www/XYZ/current/public
<Directory /www/XYZ/current/public>
AllowOverride all
Options -MultiViews
Options Indexes ExecCGI FollowSymLinks
Header always append X-Frame-Options SAMEORIGIN
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
Header Set Cache-Control "max-age=0, no-store"
</IfModule>
</VirtualHost>
blank file.
If it exist in public directory of the project, then you will be in maintenance mode else it will be in working mode.
simple HTML content to display maintenance msg.
apachectl graceful
From now we can TURN ON and TURN OFF the maintenance mode, with maintenance.enable file, without Apache restart/reload.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment