Nginx服务器中断Socket Conn On Node Proxy尽pipe节点服务器正在运行

我得到了太多[error] 17667#0: *344 connect() failed (111: Connection refused) while connecting to upstream, client:错误。 我很久没有find解决办法了。

这些是我的nginx设置。 服务器是在监听tcp 80端口的elb负载均衡器后面。 谢谢。

 user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { use epoll; worker_connections 10240; multi_accept on; } worker_rlimit_nofile 65535; http { port_in_redirect 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"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; # Cache modifikasyonları open_file_cache max=10000 inactive=10m; open_file_cache_valid 20m; open_file_cache_min_uses 1; open_file_cache_errors on; # Transfers client_body_buffer_size 10K; # client POST buffer size client_header_buffer_size 1k; # client header size client_max_body_size 20M; # allowed size for a client request large_client_header_buffers 4 32k; # number and size of buffers for large client headers output_buffers 1 32k; postpone_output 1460; # Timeouts client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; keepalive_timeout 65; keepalive_requests 100000; reset_timedout_connection on; # Gzip gzip on; gzip_comp_level 4; gzip_min_length 256; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; # Elastic Beanstalk Modification(EB_INCLUDE) log_format healthd '$msec"$uri"' '$status"$request_time"$upstream_response_time"' '$http_x_forwarded_for'; include /etc/nginx/conf.d/*.conf; # End Modification } 

在conf.d目录中只有一个conf:

 map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream nodejs { server 127.0.0.1:8081; keepalive 256; } server { listen 8080; server_name domain.com; charset utf-8; if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") { set $year $1; set $month $2; set $day $3; set $hour $4; } access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd; access_log /var/log/nginx/access.log main; location / { if ($http_x_forwarded_proto != 'https') { return 301 https://$host$request_uri; } proxy_pass http://nodejs; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering on; proxy_buffer_size 8k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } location /socket.io/ { proxy_pass http://nodejs; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering on; proxy_buffer_size 8k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } location /js/ { root /var/app/current/.tmp/public/; proxy_hide_header Set-Cookie; proxy_ignore_headers Set-Cookie; access_log off; log_not_found off; add_header Pragma "public"; add_header Cache-Control "public"; add_header X-Cache-Status $upstream_cache_status; expires max; } location /vendor/ { root /var/app/current/.tmp/public/; proxy_hide_header Set-Cookie; proxy_ignore_headers Set-Cookie; access_log off; log_not_found off; add_header Pragma "public"; add_header Cache-Control "public"; add_header X-Cache-Status Yes; expires max; } location /css/ { root /var/app/current/.tmp/public/; proxy_hide_header Set-Cookie; proxy_ignore_headers Set-Cookie; access_log off; log_not_found off; add_header Pragma "public"; add_header Cache-Control "public"; add_header X-Cache-Status Yes; expires max; } location /fonts/ { root /var/app/current/.tmp/public/; proxy_hide_header Set-Cookie; proxy_ignore_headers Set-Cookie; access_log off; log_not_found off; add_header Pragma "public"; add_header Cache-Control "public"; expires max; } location /images/ { root /var/app/current/.tmp/public/; access_log off; log_not_found off; add_header Pragma "public"; add_header Cache-Control "public"; expires max; } } 

服务器正常工作,然后破坏。 node.js应用程序没有代理服务器停机的情况。 这里是nodejs的套接字configuration:

 transports: ["websocket"], pingInterval: 10000, pingTimeout: 60000, grant3rdPartyCookie: true, allowUpgrades: true