user nginx;
worker_processes  5;
# errors to file, there should not be any
error_log  /var/log/nginx/error.log;
#error_log /dev/stdout info;
events {
  worker_connections  10240;
}
http {
  index  index.html index.htm;
  log_format  main
          'remote_addr:$remote_addr\t'
          'time_local:$time_local\t'
          'method:$request_method\t'
          'uri:$request_uri\t'
          'host:$host\t'
          'status:$status\t'
          'bytes_sent:$body_bytes_sent\t'
          'referer:$http_referer\t'
          'useragent:$http_user_agent\t'
          'forwardedfor:$http_x_forwarded_for\t'
          'request_time:$request_time';
  # logs to stdout to make it more container friendly and not fill log directory
  #access_log	/var/log/nginx/access.log main;
  access_log /dev/stdout;

  server {
      listen       80;
      server_name  _;
      root         /usr/share/nginx/html;

      # https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-nginx-on-ubuntu-14-04
      # https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/
      location /restricted/ {
        alias /usr/share/nginx/html/; 
        auth_basic "Restricted Content";
        auth_basic_user_file /usr/share/nginx/html/.htpasswd;
      }

      # for kubernetes health check
      location = /healthz {
       add_header Content-Type text/plain;
       return 200 'OK';
      }

  }
}
