Skip to content

Instantly share code, notes, and snippets.

@ricardokrieg
Last active December 19, 2015 09:59
Show Gist options
  • Save ricardokrieg/5936978 to your computer and use it in GitHub Desktop.
Save ricardokrieg/5936978 to your computer and use it in GitHub Desktop.
Nginx Maintenance Page
cp #{latest_release}/system/maintenance.html #{shared_path}/system/maintenance.html.not_active
# Swap in the maintenance page
namespace :web do
task :disable, roles: :web do
on_rollback {run "rm #{shared_path}/system/maintenance.html"}
run "if [[ !(-f #{shared_path}/system/maintenance.html) ]] ; then ln -s #{shared_path}/system/maintenance.html.not_active #{shared_path}/system/maintenance.html ; else echo 'maintenance page already up'; fi"
end
task :enable, roles: :web do
run "rm #{shared_path}/system/maintenance.html"
end
end
recursive_error_pages on;
if (-f $document_root/system/maintenance.html) {
return 503;
}
error_page 404 /404.html;
error_page 500 502 504 /500.html;
error_page 503 @503;
location @503 {
error_page 405 = /system/maintenance.html;
# Serve static assets if found.
if (-f $request_filename) {
break;
}
rewrite ^(.*)$ /system/maintenance.html break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment