githubEdit

How to setup NGINX Request Body Size

Setup NGINX Request Body Size Access your NGINX configuration file (typically located at /etc/nginx/nginx.conf) Locate the http, server, or location context where you want to modify the request body size Add or modify the following directive: client_max_body_size 20M; Note: Replace 20M with your desired maximum file size (e.g., 50M for 50 megabytes, 1G for 1 gigabyte) Save the configuration file Restart NGINX to apply the changes: sudo systemctl restart nginx or sudo service nginx restart Usage After configuring the client_max_body_size, NGINX will accept file uploads up to the specified size limit. If a user attempts to upload a file larger than the configured limit, NGINX will return a 413 (Request Entity Too Large) error. You can set different limits for different locations by adding the directive in specific location blocks: location /upload { client_max_body_size 100M; } location /api { client_max_body_size 10M; }

Last updated

Was this helpful?