Last active
August 29, 2015 13:58
-
-
Save robb-broome/9955321 to your computer and use it in GitHub Desktop.
NGINX configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! | |
%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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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