Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx returns Internal Server Error when uploading large files (several GB)

I have an Artifactory behind nginx and uploading files larger than 4 GB fails. I am fairly certain that this is nginx's fault, because if the file is uploaded from/to localhost, no problem occurs.

nginx is set up to have client_max_body_size and client_body_timeout large enough for this not to be an issue.

Still, when uploading a large file (>4 GB) via curl, after about half a minute it fails. The only error message I get is HTTP 500 Internal Server Error, nothing is written to the nginx's error logs.

like image 819
Martin Melka Avatar asked Mar 12 '23 11:03

Martin Melka


1 Answers

The problem in my case was insufficient disk space mounted on root. I have a huge disk mounted on /home, but only had about 4 GB left on /. I assume that nginx was saving incoming request bodies there and after it had filled up, the request was shut down.

The way I fixed it was to add those lines to the nginx.conf file (not all of them are necessarily required):

http {
    (...)
    client_max_body_size 100G;
    client_body_timeout 300s;

    client_body_in_file_only clean;
    client_body_buffer_size 16K;
    client_body_temp_path /home/nginx/client_body_temp;
}

The last line is the important part - there I tell nginx to fiddle with its files in the /home space.

like image 95
Martin Melka Avatar answered Apr 08 '23 17:04

Martin Melka