运行Node的我的AWS EC2实例需要将数据传递到我的Redis缓存。这已经好几个月了。但是,过去的几天里,它已经坏了。
所有请求都在大约60秒后超时,或者出现502错误。
我向节点功能添加了额外的日志记录。这表明,当服务尝试与Redis进行通信时,一切都将崩溃。
我已经多次重启了redis节点,但这没有用。我多次重建了Cloudformation堆栈,但这没有用。我已经终止并创建了新的EC2实例-效果相同。
我已经检查了以下内容:
我查看了nginx日志,发现了这点信息:
2019/01/11 09:24:33 [错误] 3826#0:* 6732上游过早关闭连接,同时从上游读取响应标头,客户端:,服务器:my.server.url, 请求:“ GET / path / of / request HTTP / 1.1”,上游:“ http://ip.ad.dr.ess:PORT/path/of/request”,主机:“ my.server.url”
我有两个Nginx配置。父母看起来像这样:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
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" - $request_time X-Forwarded-For=$http_x_forwarded_for Host=$host';
log_format KVP 'ip="$remote_addr" time="$time_local" request="$request" '
'status_code=$status request_time=$request_time '
'host="$http_host" '
'body_bytes_sent=$body_bytes_sent referrer="$http_referer" user_agent="$http_user_agent" remote_user="$remote_user"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
#sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 300s;
#gzip on;
# Load modular configuration files from the /etc/path/to/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/path/to/*.conf;
index index.html index.htm;
}
其中包括以下内容:
proxy_read_timeout 300s;
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
# A virtual host using mix of IP-, name-, and port-based configuration
#
upstream NAME_REMOVED {
server xxx.x.x.x:<%= @server_port %>;
}
server {
listen 80;
server_name <%= @server_url %>;
real_ip_header X-Forwarded-For;
# internal addresses in TEST
set_real_ip_from xx.xxx.0.0/16;
# internal addresses in PRODUCTION
set_real_ip_from xx.xxx.0.0/16;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
gzip_buffers 16 8k;
client_max_body_size 100M;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_connect_timeout 300s;
proxy_pass http://app;
proxy_redirect off;
limit_req zone=api burst=10;
}
location ~ /.git/ {
deny all;
}
}
我添加了上面显示的超时以尝试解决此问题,但效果不理想。