Skip to content

Instantly share code, notes, and snippets.

@zernel
Created November 17, 2017 09:21
Show Gist options
  • Save zernel/1cebc74d9b576ebd7860f338a2ede7b3 to your computer and use it in GitHub Desktop.
Save zernel/1cebc74d9b576ebd7860f338a2ede7b3 to your computer and use it in GitHub Desktop.
Rails Deployment (Puma + Nginx/Cathy)
https://domain {
gzip
root /apps/app/public
log dev.access.log
proxy / unix:///apps/app/tmp/sockets/puma.sock {
fail_timeout 300s
transparent
header_upstream X-Forwarded-Ssl on
except /assets /fonts /robots.txt /favicon.ico /404.html /422.html /500.html
}
}
# /etc/nginx/conf.d/app.conf
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:///apps/app/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name domain;
root /apps/app/public;
# try_files $uri/index.html $uri @app;
location / {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
location ~ ^/assets/ {
root /apps/app/public;
expires max;
gzip_static on;
gzip_vary on;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
# config/puma.rb
app_path = '/apps/app'
bind "unix://#{app_path}/tmp/sockets/puma.sock"
pidfile "#{app_path}/tmp/pids/puma.pid"
state_path "#{app_path}/tmp/sockets/puma.state"
directory "#{app_path}"
# daemonize true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment