通过对等方重置连接)同时代理升级的连接和连接到上游时拒绝连接

Bha*_*ngh 5 nginx

我的 nginx 日志中出现这些错误已经有一段时间了。我最近没有看到网站性能有任何问题,但是当我们连接了 1000 多个用户时,我们会遇到问题。

这是一些错误日志

2018/03/23 20:14:18 [error] 1356#0: *540195 recv() failed (104: Connection reset by peer) 代理升级连接时,客户端:10.253.220.93,服务器:playtest2.ea.com,请求: “GET /socket.io/?email=email&name=name&clientId=35e9c1be-f1fc-4e34-ba68-ce72c6e905c8&version=2.0.0.1704&fullName=test&EIO=3&transport=websocket&t=636573072574620756-17 HTTP / 1.1”,上游:“ HTTP: //127.0.0.1:3000/socket.io/?email=email&name=DICELA-RSTAR&clientId=35e9c1be-f1fc-4e34-ba68-ce72c6e905c8&version=2.0.0.1704&fullName=Dtest&EIO=3&transport=websocket&t=636573072574620756-17 “主持人:” playtest2.xx.com”

2018/03/23 20:14:18 [error] 1356#0: *867401 connect() 连接到上游时失败(111:连接被拒绝),客户端:10.xx.xxx.211,服务器:playtest2.xx。 com,请求:“GET /bin/PlaytestMateSetup.exe.json HTTP/1.1”,上游:“ http://127.0.0.1:3000/bin/PlaytestMateSetup.exe.json ”,主机:“playtest2.xx.com”

这是我的 nginx conf,任何帮助将不胜感激。

服务器模块列在另一个目录下。

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 30000;
debug_points abort;
worker_rlimit_core 500M;
events {
    worker_connections 8024; ## Default: 1024;
#    use epoll;
#    multi_accept on;
}

http {
    include       /etc/nginx/mime.types;
    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;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    server_names_hash_bucket_size 128;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout  180m;

    error_page 404 /offline_error.html;
        location = /offline_error.html {
                root /opt/ptm/server-src/views;
                internal;
        }

#    open_file_cache max=1000 inactive=1200s;
#    open_file_cache_valid 1800s;
#    open_file_cache_min_uses 5;
#    open_file_cache_errors off;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

}
Run Code Online (Sandbox Code Playgroud)

use*_*809 2

大海到这个https://www.nginx.com/blog/websocket-nginx/

   map $http_upgrade $connection_upgrade {
     default     upgrade;
     ''          close;
   }
   
   server xxx {
     ...
     location /socket.io/ {
       proxy_pass http://127.0.0.1:3000;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "Upgrade";
       proxy_set_header Host $host;
       proxy_connect_timeout 15s;
       proxy_send_timeout 3600s; # ws will open for 1 hour
       proxy_read_timeout 3600s; # ws will open for 1 hour
       proxy_buffers 512 256M;
       proxy_buffer_size 256M;
     }
   }
Run Code Online (Sandbox Code Playgroud)