【发布时间】:2016-08-18 01:30:32
【问题描述】:
我有一个存储在 DigitalOcean 的 Rails 应用程序。在大文件上传(~70Mb)期间,我的 Nginx 不时出现故障(可以说是 3 次)。我也有后台导入进程正在运行(但我不确定它是否与问题有关)。
我收到 502 错误,在日志中我看到 upstream permanently closed connection while reading response header from upstream。
我的nginx.conf 与此类似:
upstream backend {
server unix://var/www/my_app/shared/tmp/sockets/puma.sock;
}
server {
listen 80;
root /var/www/my_app/current/public;
client_max_body_size 600m;
proxy_connect_timeout 1200s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
client_header_timeout 1200s;
client_body_timeout 1200s;
client_header_buffer_size 1024k;
client_body_buffer_size 600m;
send_timeout 1200s;
keepalive_timeout 1200s;
large_client_header_buffers 8 1024k;
fastcgi_read_timeout 1200s;
error_log /var/www/my_app/current/log/nginx.error.log info;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 1200s;
types_hash_max_size 2048k;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
谁能建议 Nginx 一直失败的原因以及如何解决?
【问题讨论】:
-
错误信息明确指出这是上游问题。您的 Rail 应用会在发送完整响应之前关闭连接。
标签: ruby-on-rails nginx