# see https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf

worker_processes                auto; # it will be determinate automatically by the number of core

error_log  /tmp/error.log;
pid        /tmp/nginx.pid;

events {
  worker_connections          4096; ## Default: 1024
}


http {
  server_tokens off;
  absolute_redirect           off;
  access_log                  /tmp/access.log;
  default_type                application/octet-stream;
  error_log                   /tmp/error.log;
  include                     /etc/nginx/mime.types;
  keepalive_timeout           3000;
  sendfile                    on;

  server {
    listen                  8080;
    root                    /usr/share/nginx/html;
    index                   index.html;
    server_name_in_redirect on;

    add_header X-Frame-Options "deny";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    charset utf-8;

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_types text/css application/json application/javascript application/x-javascript text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

    client_max_body_size    10m;
    error_page              500 502 503 504  /50x.html;

    recursive_error_pages on;

    location / {
      # this always fallback on /index.html, never 404
      try_files $uri $uri.html $uri/index.html $uri/ /index.html;
    }

    location /50x.html {
      root                /var/lib/nginx/html;
    }

    location /live {
      default_type text/plain;
      return 200 'OK';
    }

    include /etc/nginx/ready_response.conf;
    location /ready {
        default_type text/plain;
        if ($ready_response = 'OK') {
            return 200 $ready_response;
        }
        return 500 'Not Ready';
    }

  }
}