Skip to content

Instantly share code, notes, and snippets.

@sharshenov
Last active December 5, 2016 16:45
Show Gist options
  • Save sharshenov/f4d05ed3a701133a3c35 to your computer and use it in GitHub Desktop.
Save sharshenov/f4d05ed3a701133a3c35 to your computer and use it in GitHub Desktop.
Nginx config for puma socket
upstream application {
server unix:/home/deploy/apps/APPNAME/shared/tmp/sockets/puma.sock fail_timeout=0;
}
# Optional redirect
#server {
# listen 80;
# server_name www.DOMAIN default;
# return 301 $scheme://DOMAIN$request_uri;
#}
server {
listen 80;
server_name DOMAIN;
root /home/deploy/apps/APPNAME/current/public;
try_files $uri/index.html $uri @application;
location @application {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://application;
access_log /var/log/nginx/APPNAME.access.log;
error_log /var/log/nginx/APPNAME.error.log;
}
location ~ ^/(assets|images|javascripts|stylesheets|swfs|system|uploads)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
open_file_cache max=1000 inactive=500s;
open_file_cache_valid 600s;
open_file_cache_errors on;
break;
}
client_max_body_size 10M;
keepalive_timeout 10;
error_page 500 502 504 /500.html;
error_page 503 @503;
location = /50x.html {
root html;
}
location = /404.html {
root html;
}
location @503 {
error_page 405 = /system/maintenance.html;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
}
rewrite ^(.*)$ /503.html break;
}
if ($request_method !~ ^(GET|HEAD|PUT|POST|DELETE|OPTIONS)$ ){
return 405;
}
if (-f $document_root/system/maintenance.html) {
return 503;
}
location ~ \.(php|html)$ {
return 405;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment