NGINX reverse proxy: How to increase max file upload size
8 July 2024 120 views | Tech notes
The default upload file size limit in NGINX is 1 MB, so if you are using it as a reverse proxy for your Tuskfish CMS site, you may need to increase it. You can do this globally for all sites (server level) or you can do it on a site-by-site basis.
Setting a global file size limit
Edit the main NGINX config file, usually found at /etc/nginx/nginx.conf. Add or edit the client_max_body_size directive within the http block:
http {
...
# Set max permitted file upload size
client_max_body_size 5M;
...
}
Setting per-site file size limits
Adjusting the limit on a site-by-site basis is basically the same, except you need to edit the config file for the individual site(s) in question in /etc/nginx/sites-enabled/sitename.conf. In this case, you add the directive to the server block instead:
server {
...
# Set max permitted file upload size
client_max_body_size 5M;
...
}
The value you choose should be in line with actual need. Don't go higher than you need to.
Test and apply the configuration change
To test the configuration change, run:
sudo nginx -t
If it works, reload NGINX to apply it:
sudo systemctl reload nginx
Copyright, all rights reserved.