upstream <%= app %> {
  <% ports.each do |port| %>
  server localhost:<%= port %> fail_timeout=0;
  <% end %>
}

server {
  access_log <%= log %>/<%= app %>-nginx-access.log combined buffer=0k;
  error_log  <%= log %>/<%= app %>-nginx-error.log;

  listen 80;
  server_name <%= app %>.<%= ENV['BASE_DOMAIN'] %> <%= (ENV['ADDITIONAL_DOMAINS'] || '').split(',').join(' ') %>;

  root <%= engine.root %>/public;

  gzip             on;
  gzip_min_length  1000;
  gzip_proxied     expired no-cache no-store private auth;
  gzip_types       text/javascript text/css;
  gzip_disable     "MSIE [1-6]\."

  try_files $uri/index.html $uri.html $uri @app;

  location @app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;

    proxy_pass http://<%= app %>;
  }

  error_page 500 502 503 504 /500.html;
  location = /500.html {
    root <%= engine.root %>/public;
  }
}

upstream <%= app %> {
  <% ports.each do |port| %>
  server localhost:<%= port %> fail_timeout=0;
  <% end %>
}

server {
  access_log <%= log %>/<%= app %>-nginx-access.log combined buffer=0k;
  error_log  <%= log %>/<%= app %>-nginx-error.log;

  listen 80;
  server_name <%= app %>.<%= ENV['BASE_DOMAIN'] %> <%= (ENV['ADDITIONAL_DOMAINS'] || '').split(',').join(' ') %>;

  root <%= engine.root %>/public;

  <% if ENV['GZIP_COMPRESSION'] %>
  gzip             on;
  gzip_min_length  1000;
  gzip_proxied     expired no-cache no-store private auth;
  <% if ENV['GZIP_COMPRESSION_TYPES' %>
  gzip_types       <%= ENV['GZIP_COMPRESSION_TYPES'] %>;
  <% end %>
  gzip_disable     "MSIE [1-6]\."
  <% end %>

  try_files $uri/index.html $uri.html $uri @app;

  location @app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;

    proxy_pass http://<%= app %>;
  }

  error_page 500 502 503 504 /500.html;
  location = /500.html {
    root <%= engine.root %>/public;
  }
}

Make gzip compression optional, allow custom gzip compression types
Make gzip compression optional, allow custom gzip compression types
