user  nginx;
worker_processes auto;

error_log off;

pid        /var/run/nginx.pid;

events {
    worker_connections 2048; # increase for busier servers
    use epoll; # you should use epoll here for Linux kernels 2.6.x
    multi_accept on;
    accept_mutex off;
}

worker_rlimit_nofile 20480;
#worker_priority -5;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

	server_tokens off;
	sendfile on;
	sendfile_max_chunk 512k;
	aio threads=default;
	directio 64m;  #Serve Large files like media files using directio

	tcp_nopush on;
	tcp_nodelay on;

	proxy_http_version 1.1;
	proxy_set_header Connection "";

	server_name_in_redirect on;
	server_names_hash_max_size 1024;
	server_names_hash_bucket_size 1024;

	# timeouts
	ignore_invalid_headers on;
	client_header_timeout 300;
	client_body_timeout 300;
	send_timeout 300;
	reset_timedout_connection on;
	client_body_in_file_only clean;
	keepalive_timeout 10 5;

	# gzip compression
	gzip on;
	gzip_vary on;
	gzip_disable "MSIE [1-6]\.(?!.*SV1)";
	gzip_proxied any;
	gzip_min_length 1024;
	gzip_http_version 1.1;
	gzip_comp_level 6;
	gzip_buffers 64 8k;
	gzip_types text/plain text/xml text/css application/x-javascript application/xml image/png image/x-icon image/gif image/jpeg application/xml+rss text/javascript application/atom+xml application/javascript application/json;

	# buffers
	connection_pool_size 256;
	client_body_buffer_size 128K;
	client_header_buffer_size 16k;
	large_client_header_buffers 4 32k;
	request_pool_size 4k;
	output_buffers 4 32k;
	postpone_output 1460;
	client_max_body_size 64M;

	# fastcgi settings
	fastcgi_buffers 16 16k;
	fastcgi_buffer_size 32k;
	# the below options depend on theoretical maximum of your PHP script run-time
	fastcgi_read_timeout 300;
	fastcgi_send_timeout 300;

	# open file cache
	open_file_cache          max=4096 inactive=5m;
	open_file_cache_valid    10m;
	open_file_cache_min_uses 2;
	open_file_cache_errors   on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/vhosts.d/*.conf;

}
