user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 8192; use epoll; # you should use epoll here for Linux kernels 2.6.x multi_accept on; accept_mutex off; } worker_rlimit_nofile 65535; worker_priority -10; timer_resolution 100ms; #pcre_jit on; http { server_tokens off; 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"'; #log_format json escape=json '{"source": "nginx", "time": $msec, "resp_body_size": $body_bytes_sent, "host": "$http_host", "address": "$remote_addr", "request_length": $request_length, "method": "$request_method", "uri": "$request_uri", "status": $status, "user_agent": "$http_user_agent", "resp_time": $request_time, "upstream_addr": "$upstream_addr"}'; # log_format json escape=json '{"remote_addr": "$http_x_forwarded_for", ' # '"host": "$host", ' # '"remote_user": "$remote_user", ' # '"time": "$time_local", ' # '"request": "$request", ' # '"status": "$status", ' # '"body_bytes_sent": "$body_bytes_sent",' # '"http_referer": "$http_referer",' # '"http_user_agent": "$http_user_agent",' # '"upstrm": "$upstream_response_time",' # '"took": "$request_time",' # '"upstream_addr": "$upstream_addr"}'; # #log_format json escape=json '{ "timestamp": "$time_iso8601", ' #'"remote_addr": "$remote_addr", ' #'"remote_user": "$remote_user", ' #'"request_url": "$request_uri", ' #'"req_status": "$status", ' #'"response_size_B": "$bytes_sent", ' #'"req_protocol": "$server_protocol",' #'"req_method": "$request_method",' #'"req_srvname": "$server_name",' #'"req_time": "$request_time",' #'"connection-id": "$request_id",' #'"ssl_prot_version": "$ssl_protocol",' #'"ssl_cipher": "$ssl_cipher",' #'"ssl_conn_reused": "$ssl_session_reused",' #'"ssl_session_id": "$ssl_session_id",' #'"http_referrer": "$http_referer", ' #'"http_user_agent": "$http_user_agent", ' #'"http_x_referer": "$http_x_referer" }'; sendfile on; sendfile_max_chunk 512k; #aio threads=iopool; #directio 1m; #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 90; client_body_timeout 90; send_timeout 90; reset_timedout_connection on; client_body_in_file_only clean; keepalive_requests 2048; keepalive_timeout 10s; # gzip compression gzip on; gzip_vary on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_proxied any; gzip_min_length 1000; gzip_http_version 1.1; gzip_comp_level 6; gzip_buffers 64 8k; gzip_types text/plain text/xml image/svg+xml application/rss+xml application/atom+xml application/xhtml+xml text/css application/json text/javascript application/x-javascript application/font-otf application/font-ttf; # buffers connection_pool_size 1024; client_body_buffer_size 4M; client_header_buffer_size 64k; large_client_header_buffers 4 64k; request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 64M; # the below options depend on theoretical maximum of your PHP script run-time fastcgi_connect_timeout 60s; fastcgi_read_timeout 300s; fastcgi_send_timeout 300s; # open file cache open_file_cache max=5000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 5; open_file_cache_errors on; # Cloudflare include /etc/nginx/cloudflare.conf; include /etc/nginx/conf.d/*.conf; }