user nginx; pid /var/run/nginx.pid; worker_processes auto; worker_rlimit_nofile 300000; # needs to be < ulimit -n error_log /data/nginx/logs/nginx-error.log warn; events { worker_connections 40000; multi_accept on; } http { # aggressive caching for read-only sources open_file_cache max=1000000 inactive=60m; open_file_cache_valid 60m; open_file_cache_min_uses 1; open_file_cache_errors on; server_tokens off; include /etc/nginx/mime.types; types { application/x-protobuf pbf; } default_type application/octet-stream; charset utf-8; sendfile on; tcp_nopush on; tcp_nodelay on; reset_timedout_connection on; send_timeout 20; max_ranges 0; gzip on; gzip_comp_level 1; gzip_types application/json application/x-protobuf; log_format access_json '{' # general '"time": "$time_iso8601", ' '"status": $status, ' #'"request_method": "$request_method", ' #'"uri": "$uri", ' #'"request": "$request", ' #'"request_time": $request_time, ' '"body_bytes_sent": $body_bytes_sent, ' '"http_referrer": "$http_referer", ' '"http_user_agent": "$http_user_agent", ' #'"scheme": "$scheme", ' #'"host": "$host", ' #'"http_host": "$http_host", ' # IP address related # IP address logging is disabled #'"remote_addr": "$remote_addr", ' #'"http_x_forwarded_for": "$http_x_forwarded_for", ' # CF related #'"http_cf_ray": "$http_cf_ray", ' #'"http_cf_ipcountry": "$http_cf_ipcountry", ' #'"http_cf_connecting_ip": "$http_cf_connecting_ip", ' '"_": "_"' # helper for no trailing comma '}'; access_log off; #access_log /data/nginx/logs/nginx-access.log access_json buffer=128k; include /data/nginx/config/*; include /data/nginx/sites/*; }