In this article, we will demonstrate how to limit file upload size in Nginx. One of the most common errors system admins encounter is when users complain that their file upload couldn’t complete. The error associated with this issue is client intended to send too large body and can be found in /var/log/nginx/error.log.
Apart from the need to increase the file upload size, webmasters or sysadmins need to restrict the file upload size to prevent some types of denial-of-service (DOS) attacks.
By default, Nginx has a limit of 1MB for file uploads. The directive responsible for this is the client_max_body_size which is part of the Nginx’s ngx_http_core_module.
In order to change the default 1MB limit, you need to use the directive in /etc/nginx/nginx.conf file as follows:
- Set in http block (affects all virtual hosts)
http {
...
client_max_body_size 100M;
}
2. Set in server block (affects a particular virtual host)
server {
...
client_max_body_size 100M;
}
3. Set in php block (affects all php files within a site/app)
location ~ \.php$ {
...
client_max_body_size 100M;
}
Once you do the necessary changes, save the nginx.conf file and restart the Nginx web server to apply the changes, as follows:
nginx -t // dry-run to ensure no syntax errors exist
systemctl restart nginx // restart to apply the saved changes
Mastering the Forex Market: Unleashing the Power of Dedicated Servers for MT5 Hosting
Dedicated Servers in 2025: Why Businesses Are Moving Back
NetShop ISP Expands Global Reach with PoP VPS Solution
MT5 Access Server for Forex Brokers: Virtual vs. Dedicated
6 Reasons Why Your WordPress Website Is Slow And How to Fix It
How To Setup DKIM and SPF Records on cPanel (Jupiter theme)
5 Advantages of Colocation Vs. On Premise Hosting
All You Need to Know about Data Center Reliability Levels (Tiers)
XConnect: Ultra‑Low Latency Connectivity Now Delivered Globally
Cloud Hosting Trends 2025: Bare Metal, Hybrid Cloud & Web3 Hosting
Introducing Hybrid & Workload-based Cloud Backup Solutions
How can Forex Brokers be Protected from DDoS Attacks






