We had the same issue while uploading the large files. The culprit was the client_body_buffer_size setting. It was set to 200MB. Basically, the buffer was too big and nginx was not able to allocate so much memory for keeping the file inside it. We had to lower the buffer to a normal value, so that file is buffered to a temp file during upload and the issue was resolved. Here is a detailed explanation.