Unable to upload file on nginx with Ubuntu 20.04 and nodejs

I’m trying to upload files from an app to a nodejs api on digital ocean using nginx as a reverse proxy. I’m using multer to upload form-data, and it works well in my local environment, so I suppose the problem is with nginx.

I have tried various configurations for nginx.conf and the configuration file at /etc/nginx/sites-available/ (setting client_max_body_size and client_body_buffer_size to larger values, disabling proxy_request_buffering, etc), and even tried the whole process with a 60kb file. I’m not getting the 413 error, so setting larger values for some nginx config variables did work, but the file never appears inside the req object (which multer was supposed to extract).

Any tips on how to solve this problem?


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.

Just in case anyone has this same problem, it was specific to multer. I fixed it by by passing multer as middleware to the router. Interestingly one can use multer directly inside the router function in a local environment without any problems.