Created
January 19, 2012 16:19
-
-
Save joequery/1640945 to your computer and use it in GitHub Desktop.
Nginx individual site config for multiple rails apps with Unicorn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################## | |
# 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