server {
  server_name <%= fetch(:server_name) %>;
  listen 80;
  passenger_enabled on;
  rails_env    production;
  root <%= fetch(:deploy_to) %>/current/public;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }
  
  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;
  passenger_enabled on;
  rails_env    production;
  root <%= fetch(:deploy_to) %>/current/public;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  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 %>
