Skip to content

Instantly share code, notes, and snippets.

@joekr
Last active December 25, 2015 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joekr/6923504 to your computer and use it in GitHub Desktop.
Save joekr/6923504 to your computer and use it in GitHub Desktop.
nginx sites-enabled file for generic rails project using unicorn
upstream unicorn_server {
# This is the socket we configured in unicorn.rb
server unix:/srv/www/example/shared/sockets/unicorn.sock fail_timeout=0;
}
server{
listen 80 default;
server_name example;
root /srv/www/example/current/public;
try_files $uri/index.html $uri.html $uri @unicorn;
underscores_in_headers on;
location @unicorn {
# lock down hosts
if ($host !~ ^(example.com)$ ) {
return 444;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header ACCESS_ID $http_access_id;
proxy_set_header Access-ID2 $http_access_id;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_server;
}
# example of redirecting to an external blog
#location /blog/ {
# proxy_pass http://example.com/blog/;
#
# proxy_read_timeout 600;
#
# proxy_set_header X-Real-IP 173.254.28.119;
# proxy_set_header Host $host;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /srv/www/example/current/public;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment