Skip to content

Instantly share code, notes, and snippets.

@jancuk
Created May 22, 2015 17:56
Show Gist options
  • Save jancuk/ae7818845d49822c6319 to your computer and use it in GitHub Desktop.
Save jancuk/ae7818845d49822c6319 to your computer and use it in GitHub Desktop.
unicorn localhost rails
upstream app_rails {
server unix:/path/rails_app.sock;
}
server {
listen *:80;
client_max_body_size 50M;
root path/rails_app;
access_log /var/log/nginx/access_log.log;
error_log /var/log/nginx/error_log.log;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
rewrite ^/~([^/]*)(/|$)(.*)$ /$3 break;
try_files $uri/index.html $uri.html @rails;
}
location @rails {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass http://app_rails;
}
location = /500.html {
root /path/public;
}
location ~* \.(xml|css|gif|txt|swf|ad|ico|js|jpg|jpeg|png|htc|eot|ttf|svg|woff)$ {
try_files $uri @rails;
expires 1d;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment