upstream unicorn_<%= node[:application] %> { # This is the socket we configured in unicorn.rb server unix:<%= node[:shared_path] %>/sockets/unicorn.sock fail_timeout=0; } server { server_name <%= node[:railsapp][:server_names] %>; listen 80; root <%= node[:current_path] %>/public; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout <%= node[:railsapp][:request_timeout] %>s; # If you don't find the filename in the static files # Then request it from the unicorn server if (!-f $request_filename) { proxy_pass http://unicorn_<%= node[:application] %>; break; } } location ~ ^/(assets)/ { gzip_static on; access_log off; expires max; add_header Cache-Control public; add_header Last-Modified ""; add_header ETag ""; } } <% if node[:railsapp][:ssl] %> server { listen 443; server_name <%= node[:railsapp][:server_names] %>; ssl on; ssl_protocols SSLv3 TLSv1; ssl_certificate <%= node[:current_path] %>/<%= node[:railsapp][:ssl_crt_path] %>; ssl_certificate_key <%= node[:current_path] %>/<%= node[:railsapp][:ssl_key_path] %>; proxy_set_header X-FORWARDED_PROTO https; root <%= node[:current_path] %>/public; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout <%= node[:railsapp][:request_timeout] %>s; # If you don't find the filename in the static files # Then request it from the unicorn server if (!-f $request_filename) { proxy_pass http://unicorn_<%= node[:application] %>; break; } } } <% end %>