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.

Revisions

  1. zernel created this gist Nov 17, 2017.
    12 changes: 12 additions & 0 deletions Caddyfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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

    }
    }
    33 changes: 33 additions & 0 deletions Nginx Conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    # /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;
    }
    8 changes: 8 additions & 0 deletions Puma Config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # 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