# user www-data;
pid /tmp/nginx.pid;
worker_processes auto;

events {
    worker_connections 1024;
}

http {
	charset utf-8;

	# copies data between one FD and other from within the kernel
  # faster than read() + write()
  sendfile on;

	# send headers in one piece, it is better than sending them one by one
  tcp_nopush on;

  # don't buffer data sent, good for small data bursts in real time
  tcp_nodelay on;

  # allow the server to close connection on non responding client, this will free up memory
  reset_timedout_connection on;

  # hide server info for security
	server_tokens off;

	log_not_found off;
	types_hash_max_size 2048;

  # if the request body size is more than the buffer size, then the entire (or partial)
  # request body is written into a temporary file
  client_body_buffer_size  128k;

    # maximum body size
	client_max_body_size 16M;

	# maximum number and size of buffers for large headers to read from client request
  large_client_header_buffers 4 256k;

  # cache information about FDs, frequently accessed files
  open_file_cache max=200000 inactive=20s;
  open_file_cache_valid 60s;
  open_file_cache_min_uses 5;
  open_file_cache_errors off;

	# MIME
	include mime.types;
	default_type application/octet-stream;

	# enhancment
	# Replace loadbalancer IP(real-ip) with actual client IP.
	set_real_ip_from  0.0.0.0/0;
  real_ip_header    X-Forwarded-For;
  real_ip_recursive on;

	# load configs
	include /etc/nginx/conf.d/*.conf;
}