我已经在我的nginx日志中得到这些错误了很长一段时间了。 我最近没有看到网站性能的任何问题,但是当我们有超过1000个用户连接时,我们遇到了问题。
以下是一些错误日志
2018/03/23 20:14:18 [错误] 1356#0:* 540195 recv()失败(104: 在代理升级连接时,对等方重置连接,客户端: 10.253.220.93,server:playtest2.ea.com,request:" 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&#34 ;, 主持人:" playtest2.xx.com"
2018/03/23 20:14:18 [错误] 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;
}
答案 0 :(得分:0)
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;
}
}