简体   繁体   中英

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. 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.

It seems to work for files sized upto around 90MB but does not work for larger files.

My nginx config is as follows:

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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