Question

1GB File Upload Failure - 502 Bad Gateway

Hi @Everyone, My MERN stack doesn’t allow clients to upload more than 1GB files, while 800MB, 300M ,and 50MB file uploads worked correctly.

After uploading progress reaches100%, it immediately retrieves 502 Bad Gateway responses.


Here is the server log:

2022/03/03 14:54:15 [error] 2614707#2614707: *7 upstream prematurely closed connection while reading response header from upstream, client: 80.237.47.16, server: xxx.com, request: “POST /api/modules/uploadFile HTTP/1.1”, upstream: “http://127.0.0.1:5000/api/modules/uploadFile”, host: “www.xxx.com”, referrer: “https://www.xxx.com/modules/edit/621fb81865634689d4c68141


/etc/nginx/sites-available/default

    proxy_max_temp_file_size 0;
    proxy_connect_timeout 1800s;
    proxy_send_timeout 1800s;
    proxy_read_timeout 1800s;
    proxy_buffer_size 128k;
    proxy_buffers 128 256k;
    proxy_busy_buffers_size 256k;
    proxy_redirect off;
    proxy_request_buffering off;
    proxy_buffering off;

/etc/nginx/nginx.conf

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 1800;
    types_hash_max_size 2048;
    client_max_body_size 4096M;
    fastcgi_read_timeout 1800s;
    client_body_timeout 1800s;
    client_header_timeout 1800s;
    # server_tokens off;

    ...

Could anyone recommend any solutions,please? Thank you

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

The Nginx configuration looks correct, according to the error that you’ve shared your Node backend service is closing the connection prematurely, do you see any errors in your Node application?

Best,

Bobby

try to direct upload via ftp