While trying to upload a file to a web app using NGINX as a reverse proxy, I encountered the following error:

...
Save(<data/c5ceb2d914>) returned error, retrying after 19.847451977s: client.PutObject: <html>Documents/Fonts/FiraCode.zip
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.20.1</center>
</body>
</html>
Save(<data/d194099394>) returned error, retrying after 36.899440019s: client.PutObject: <html>Documents/Fonts/FiraCode.zip
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.20.1</center>
</body>
</html>
...

It turned out that NGINX has default value for file upload limit to 1 MB set in client_max_body_size variable. Therefore, I need to increase the file upload size to something bigger, says 50 MB. Where to update this file? Well, we can apply this change to the main NGINX’s configuration file, e.g. /etc/nginx/nginx.conf or specifically in the configuration file for the web app. I chose the latter for my case.

Here is a sample change in /etc/nginx/conf.d/my_app.conf

# nginx -T | grep client_max -B1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

      # [2024-11-04] set client body size to 100 MB - fix 413 request entity too large
      client_max_body_size 50M;

Restart the nginx service, and the error was gone.

References: