Skip to content

Instantly share code, notes, and snippets.

@scudco
Created August 7, 2013 22:20
Show Gist options
  • Save scudco/6179383 to your computer and use it in GitHub Desktop.
Save scudco/6179383 to your computer and use it in GitHub Desktop.
Basic configuration for nginx with rails app using unicorn
upstream appname_unicorn {
server unix:/var/www/appname/shared/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.domain-name.com;
rewrite ^(.*) http://domain-name.com$1 permanent;
}
server {
listen 80;
server_name domain-name.com *.domain-name.com;
root /var/www/appname/current/public;
location / {
try_files $uri @appname;
}
location @appname {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://appname_unicorn;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment