worker_processes 1;
daemon off;

error_log /home/vcap/app/nginx/logs/error.log;
events { worker_connections 1024; }

http {
  charset utf-8;
  log_format cloudfoundry '$http_x_forwarded_for - $http_referer - [$time_local] "$request" $status $body_bytes_sent';
  access_log /home/vcap/app/nginx/logs/access.log cloudfoundry;
  default_type application/octet-stream;
  include mime.types;
  sendfile on;

  gzip on;
  gzip_disable "msie6";
  gzip_comp_level 6;
  gzip_min_length 1100;
  gzip_buffers 16 8k;
  gzip_proxied any;
  gunzip on;
  gzip_static always;
  gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss;
  gzip_vary on;

  tcp_nopush on;
  keepalive_timeout 30;
  port_in_redirect off; # Ensure that redirects don't include the internal container PORT - 8080
  server_tokens off;

  server {
    listen 8080;
    server_name localhost;

    root /home/vcap/app/public;

    location / {
      return 503;
    }

    location /static_503 {
    }

    error_page 503 @maintenance;

    location @maintenance {
      rewrite ^(.*)$ /index.html break;
    }

    location ~ /\. {
      deny all;
      return 404;
    }

  }
}
