worker_processes auto; worker_rlimit_nofile 65535; events { worker_connections 4096; use epoll; multi_accept on; accept_mutex off; } http { access_log off; error_log /dev/null crit; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; keepalive_requests 1000000; client_max_body_size 1k; client_body_timeout 1s; client_header_timeout 1s; upstream backend_pool { least_conn; server api1:9999 max_fails=1 fail_timeout=1s weight=1; server api2:9999 max_fails=1 fail_timeout=1s weight=1; keepalive 3072; keepalive_requests 100000; keepalive_timeout 120s; } server { listen 9999 default_server; location / { proxy_pass http://backend_pool; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_buffering off; proxy_cache off; proxy_store off; proxy_connect_timeout 100ms; proxy_send_timeout 2s; proxy_read_timeout 2s; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; } } }