Last active
August 29, 2015 14:21
-
-
Save jbodah/45090bcae87d1af44e14 to your computer and use it in GitHub Desktop.
nginx unicorn example
This file contains hidden or 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
# /etc/nginx/sites-enabled/default.conf | |
upstream unicorn_server { | |
# Path to Unicorn SOCK file, as defined previously | |
server unix:/home/vagrant/buildo/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name localhost; | |
# Application root, as defined previously | |
root /home/vagrant/buildo/public; | |
location / { | |
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; | |
# pass to the upstream unicorn server | |
proxy_pass http://unicorn_server; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} | |
# /home/vagrant/buildo/unicorn.rb | |
# set path to app that will be used to configure unicorn, | |
# note the trailing slash in this example | |
@dir = '/home/vagrant/buildo/' | |
worker_processes 2 | |
working_directory @dir | |
timeout 30 | |
# Specify path to socket unicorn listens to, | |
# we will use this in our nginx.conf later | |
listen "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64 | |
# Set process id path | |
pid "#{@dir}tmp/pids/unicorn.pid" | |
# Set log file paths | |
stderr_path "#{@dir}log/unicorn.stderr.log" | |
stdout_path "#{@dir}log/unicorn.stdout.log" | |
# in shell | |
unicorn -c unicorn.rb -D | |
sudo service nginx reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment