upstream prematurely closes cnx => 502 Bad Gateway to client

stefws nginx-forum at forum.nginx.org
Thu Mar 3 10:57:36 UTC 2016


My config btw: 

user  imail;
worker_processes  auto;
daemon on;
master_process on;
error_log  logs/mos_error.tcp  debug_tcp;
error_log  logs/mos_error.log;
pid        /opt/imail/nginx/logs/mos_nginx.pid;
worker_rlimit_nofile 200000;
worker_rlimit_core  500M;
working_directory   /opt/imail/nginx;
events {
    worker_connections  25000;
    use epoll;
    multi_accept off;
}
http {
    log_format testlogs '$remote_addr - $remote_user [$time_local]  '
     '"$request" $status $body_bytes_sent '
     '"$http_referer" "$upstream_addr" '
     '$request_time $upstream_response_time';
    access_log logs/mos_access.log;
    sendfile on;
    keepalive_requests 500000;
    keepalive_timeout 20s;
    tcp_nopush on;
    tcp_nodelay on;
    client_body_buffer_size 128k;
    client_body_temp_path /dev/shm/mos_nginx/client_temp 1 2;
    open_file_cache max=25000 inactive=30s;
    open_file_cache_valid    60s;
    open_file_cache_min_uses 2;
    open_file_cache_errors   on;
    upstream mosgenericbackend {
        server mss1:8081;
        server mss2:8081;
        server mss3:8081;
        server mss4:8081;
        healthcheck_enabled;
        healthcheck_delay 1000;
        healthcheck_timeout 1000;
        healthcheck_failcount 2;
        healthcheck_send 'GET /mxos/monitor HTTP/1.0';
        keepalive 300;
    }
    server {
        listen 8081;
        keepalive_timeout 600s;
        client_max_body_size 0;
        location /mxos/ {
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_pass http://mosgenericbackend;
            proxy_connect_timeout 2;          
            more_set_headers "Content-Type: application/json";
        }
        location /mxos/health_status {
            healthcheck_status;
        }
        proxy_connect_timeout 60;
        proxy_read_timeout  30;
        proxy_send_timeout 60;
    }
}

My [vendor patched/supplied due to application specific load
balancing+health check] nginx version:

# /opt/imail/nginx/sbin/nginx -V
nginx version: nginx/1.7.4
built by gcc 3.4.6 20060404 (Red Hat 3.4.6-3)
TLS SNI support disabled
configure arguments: --with-debug
--add-module=/bld/current/emailmx90_git_blds/emailmx90_contrib_shared/contrib/nginx_1.7.4/source/addons/healthcheck_nginx_upstreams-master
--add-module=/bld/current/emailmx90_git_blds/emailmx90_contrib_shared/contrib/nginx_1.7.4/source/addons/headers-more-nginx-module-0.23
--add-module=/bld/current/emailmx90_git_blds/emailmx90_contrib_shared/contrib/nginx_1.7.4/source/addons/yaoweibin-nginx_tcp_proxy_module-f2156ef

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,265031,265032#msg-265032



More information about the nginx mailing list