加载资源失败:服务器响应状态为 504(从服务器读取响应时超时)Node.js,Nginx

Failed to load resource: the server responded with a status of 504 (Timeout while reading response from Server) Node.js,Nginx

尝试上传大文件时,出现 504 超时错误。使用 node.js/multer 、 cloudflare 、 nginx 、 ec2。网络不是很好,上传文件需要时间,上传 4-7 分钟后超时。没有发现完全相同的超时时间,它总是随机的

在服务器的 Nginx 配置中,您可能需要更改限制

client_max_body_size 5M;

到 10M 或任何您的最大文件大小

client_max_body_size 10M;

加上如果使用 nginx 代理也增加超时限制

proxy_connect_timeout       600;
proxy_send_timeout          600;
proxy_read_timeout          600;
send_timeout                600;

这可能是由于 Cloudflare 免费包限制您上传大于 50mb 的文件。