简体   繁体   English

为什么我在 AWS EC2 实例上的 nodejs 应用程序的大文件上传失败并显示状态 413?

[英]Why does large file upload fail with status 413 for my nodejs app on AWS EC2 instance?

I am posting the file using multipart form and uploading to s3.我正在使用多部分表单发布文件并上传到 s3。 The application works fine on local.该应用程序在本地运行良好。

When I upload a small file then it works fine.当我上传一个小文件时,它工作正常。 However, when I upload larger files then the upload fails with status code 413.但是,当我上传较大的文件时,上传失败,状态码为 413。

It seems to work for files sized upto around 90MB but does not work for larger files.它似乎适用于大小高达 90MB 左右的文件,但不适用于较大的文件。

My nginx config is as follows:我的 nginx 配置如下:

server {
    listen 80;
    server_name mydomain.com;
    location / {
        client_max_body_size 500M;
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
     }
}

Turns out the issue was with cloudflare.原来问题出在 cloudflare 上。 The maximum upload size limit for cloudflare is 100MB in the free tier and even with paid plans, the limit is increased to around 200MB which does not fit my requirements. Cloudflare 在免费层的最大上传大小限制为 100MB,即使有付费计划,限制也会增加到 200MB 左右,这不符合我的要求。

Earlier, I was sending the file to my server and uploading it from there, but now I bypassed that by using presigned PUT url to upload the object directly to S3 from my browser.早些时候,我将文件发送到我的服务器并从那里上传,但现在我绕过了它,使用预签名的 PUT url 从浏览器将 object 直接上传到 S3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM