Skip to content

Instantly share code, notes, and snippets.

@alobato
Created April 30, 2013 01:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alobato/5486079 to your computer and use it in GitHub Desktop.
Save alobato/5486079 to your computer and use it in GitHub Desktop.
# use the socket we configured in our unicorn.rb
upstream unicorn_APPNAME {
server unix:/tmp/unicorn.APPNAME.sock fail_timeout=0;
}
server {
listen 80;
server_name DOMAIN;
rewrite ^/(.*) http://www.DOMAIN/$1 permanent;
access_log /dev/null;
error_log /dev/null;
}
server {
listen 80;
server_name www.DOMAIN;
root /home/deployer/apps/APPNAME/current/public;
try_files $uri/index.html $uri @unicorn_APPNAME;
error_page 500 502 503 504 /500.html;
# maximum accepted body size of client request
client_max_body_size 4G;
# the server will close connections after this time
keepalive_timeout 10;
access_log /dev/null;
error_log /dev/null;
location @unicorn_APPNAME {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
# pass to the upstream unicorn server mentioned above
proxy_pass http://unicorn_APPNAME;
}
# http://stackoverflow.com/a/6952804
# https://gist.github.com/mikhailov/3052776
# http://stackoverflow.com/a/7411613
# http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets
location ~ ^/assets/ {
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment