Skip to content

Instantly share code, notes, and snippets.

@rottmanj
Created September 13, 2012 23:58
Show Gist options
  • Save rottmanj/3718765 to your computer and use it in GitHub Desktop.
Save rottmanj/3718765 to your computer and use it in GitHub Desktop.
nginx config
upstream unicorn-<%=webistrano_stage %> {
server unix:<%= current_path %>/tmp/sockets/unicorn-<%= webistrano_stage %>.sock fail_timeout=0;
}
server {
listen <%= current_ip %>:80 default deferred;
server_name <%= domain %>;
root <%= current_path %>/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_pass http://unicorn-<%=webistrano_stage %>;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https; # for SSL, add this
}
error_page 502 503 /maintenance.html;
error_page 500 504 /500.html;
keepalive_timeout 5;
}
server {
listen <%= current_ip %>:443 default;
ssl on;
ssl_certificate <%= shared_path %>/certs/<%= certificate_name %>.crt;
ssl_certificate_key <%= shared_path %>/certs/<%= certificate_name %>.key;
server_name <%= domain %>;
root <%= current_path %>/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_pass http://unicorn-<%=webistrano_stage %>;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https; # for SSL, add this
}
error_page 502 503 /maintenance.html;
error_page 500 504 /500.html;
keepalive_timeout 5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment