Skip to content

Instantly share code, notes, and snippets.

@gordonbisnor
Created November 10, 2014 23:41
Show Gist options
  • Select an option

  • Save gordonbisnor/aa197bb9a192ff3ebc77 to your computer and use it in GitHub Desktop.

Select an option

Save gordonbisnor/aa197bb9a192ff3ebc77 to your computer and use it in GitHub Desktop.
Nginx Conf Example Where Multiple Apps Deployed (Based on Talking Quickly book and blog posts)
upstream unicorn_thisapp {
server unix:/tmp/unicorn.<%= fetch(:full_app_name) %>.sock fail_timeout=0;
}
server {
server_name <%= fetch(:server_name) %>;
listen 80;
root <%= fetch(:deploy_to) %>/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn_thisapp;
location @unicorn_thisapp {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_thisapp;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
<% if fetch(:enable_ssl) %>
server {
server_name <%= fetch(:server_name) %>;
listen 443;
root <%= fetch(:deploy_to) %>/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn_thisapp;
location @unicorn_thisapp {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_thisapp;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
ssl on;
ssl_certificate <%= fetch(:deploy_to) %>/shared/ssl_cert.crt;
ssl_certificate_key <%= fetch(:deploy_to) %>/shared/ssl_private_key.key;
}#
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment