Skip to content

Instantly share code, notes, and snippets.

@ZephiroRB
Last active July 25, 2017 22:04
Show Gist options
  • Save ZephiroRB/8d1e87f66a444ddab9c3 to your computer and use it in GitHub Desktop.
Save ZephiroRB/8d1e87f66a444ddab9c3 to your computer and use it in GitHub Desktop.
Setup Rails
Rails.application.config.generators do |g|
g.test_framework :false
g.helper false
g.assets false
g.view_specs false
end
upstream railsapp {
server unix:/var/run/puma_app.sock fail_timeout=0;
}
server {
listen 80;
server_name railsdomain;
root railspath/public;
client_max_body_size 4G;
keepalive_timeout 10;
access_log off;
error_log off;
add_header X-Powered-By "Carlos Montalvo (http://www.zetanova.com)";
if ($request_method !~ ^(GET|HEAD|PUT|POST|DELETE|OPTIONS)$ ){
return 405;
}
location ~ ^/(assets)/ {
root railspath/public;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
location = /favicon.ico {
expires max;
add_header Cache-Control public;
}
# this rewrites all the requests to the maintenance.html
# page if it exists in the doc root. This is for capistrano's
# disable web task
if (-f $document_root/maintenance.html) {
rewrite ^(.*)$ /maintenance.html last;
break;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
error_page 500 504 /500.html;
error_page 502 /502.html;
error_page 503 /503.html;
if (-f $request_filename) {
expires max;
break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://railsapp;
break;
}
}
location ~ \.php$ {
deny all;
}
}
#!/usr/bin/env puma
environment 'development'
daemonize true
app = "app"
app_path = "app_path"
pidfile "#{app_path}/puma_#{app}.pid"
state_path "#{app_path}/puma_#{app}.state"
stdout_redirect "#{app_path}/log/puma_#{app}.log", "#{app_path}/log/puma_err_#{app}.log"
# quiet
threads 0, 16
bind "unix:#{app_path}/puma_#{app}.sock"
workers 2
activate_control_app "unix:#{app_path}/pumactl_#{app}.sock"
Rails.application.config.assets.paths << Rails.root.join("app", "assets", "fonts")
Rails.application.config.assets.precompile += %w( zetanova.css zetanova.js )
Rails.application.config.middleware.use Rack::Deflater
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment