Skip to content

Instantly share code, notes, and snippets.

@robb-broome
Last active August 29, 2015 13:58
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 robb-broome/9955321 to your computer and use it in GitHub Desktop.
Save robb-broome/9955321 to your computer and use it in GitHub Desktop.
NGINX configuration
# i am in /etc/nginx/sites-available/
if (-f $document_root/system/maintenance.html) {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
namespace :deploy do
namespace :web do
task :disable, :roles => :web, :except => { :no_release => true } do
require 'haml'
on_rollback { run "rm #{shared_path}/public/maintenance.html" }
reason = ENV['REASON']
deadline = ENV['UNTIL']
template = File.read("./app/views/layouts/maintenance.html.haml")
result = Haml::Engine.new(template).render
put result, "#{shared_path}/system/maintenance.html", :mode => 0644
end
end
end
!!!
%html
%head
%title Blog
:css
html, body {
background-color: #4B7399;
font-family: Verdana, Helvetica, Arial;
font-size: 14px;
}
a {
color: #0000FF;
img { border: none; }
}
#container {
width: 80%;
margin: 0 auto;
background-color: #FFF;
padding: 20px 40px;
border: solid 1px black;
margin-top: 20px;
}
%body
#container
%h1
The system is down for #{reason ? reason : "maintenance"}
%p
It will be back #{deadline ? deadline : "soon"}
upstream unicorn {
server unix:/opt/apps/maps/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /opt/apps/maps/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment