Skip to content

@joequery /gist:1640945
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Nginx individual site config for multiple rails apps with Unicorn
##############################################################
# Upstream must have unique name and unique socket. #
# The socket must match what is in the app's unicorn.rb file #
##############################################################
upstream railsapp1_server {
server unix:/tmp/railsapp1.sock fail_timeout=0;
}
##############################
# Rewrite www to non-www #
##############################
server{
server_name www.railsapp1.com;
rewrite ^(.*) http://railsapp1.com$1 permanent;
}
##############################
# Server configs go here #
##############################
server {
listen 80;
client_max_body_size 4G;
server_name railsapp1.com;
keepalive_timeout 5;
#########################################################
# This should go to the public folder of your rails app #
#########################################################
root /var/www/railsapp1.com/current/public;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
#############################################
# This should be http://upstream; with the #
# upstream specified above. #
#############################################
proxy_pass http://railsapp1_server;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
#########################################################
# This should go to the public folder of your rails app #
#########################################################
root /var/www/railsapp1.com/current/public;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.