Flash Sale

2 x Quad Core Intel Xeon 2.4GHz @ €85/mo (Amsterdam)

Buy Now
How To Increase File Upload Size in Nginx Web Server

How To Increase File Upload Size in Nginx Web Server

NetShop ISP

NetShop ISP · Blog Author

Nov 23, 2021 · Tutorials

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:

  1. 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

Related Articles

Categories

Backup
6
Business Continuity
4
Cloud Hosting
9
Colocation
4
Company Updates
1
Cryptocurrencies
1
Data Centers
11
Dedicated Servers
3
Disaster Recovery
1
Forex
14
Gaming
1
iGaming
29
Industry News
30
Interviews
7
Joomla
9
Magento
4
Managed Services
1
Press Releases
40
Product News
6
Resellers
1
Security
21
Streaming
1
Tech Startups
12
Tutorials
29
Uncategorized
389
Vps Hosting
9
Web Design & Development
3
Web Hosting
41
Webinars
1
Wordpress
14

Free VPS Trial

No Credit Card Required.

Recent Posts

NetShop ISP launch their biggest Flash Sale yet

NetShop ISP launch their biggest Flash Sale yet

24 January, 2022

How To Fix Error nf_conntrack table full dropping packet in Linux Servers

How To Fix Error nf_conntrack table full dropping packet in Linux Servers

20 January, 2022

Top 5 Features your Media Streaming Host Should Have

Top 5 Features your Media Streaming Host Should Have

18 January, 2022

iGaming in Malta: Free Guide for Database Replication Server Hosting

iGaming in Malta: Free Guide for Database Replication Server Hosting

11 January, 2022

RIPE NCC – Internet Country Report: Cyprus, Malta, Israel

RIPE NCC – Internet Country Report: Cyprus, Malta, Israel

05 January, 2022

Products

Bare Metal Dedicated Servers

Virtual Servers (VPS / VDS)

Rack Space & Colocation Hosting

Fast Web Hosting

Cloud Backup

Premium DNS Hosting

Company

About Us

Careers

Blog

Videos

WebinarsNew

Awards & Honours

Become a Partner

Contact Us

#letushostyou

Award Winning Hosting Provider with a Customer-centric approach to Business and an Open Source Mindset regarding Solutions and Products Development.

Est. 2004, Larnaca – Cyprus


About

Legal Address: 2A, Marathonos, Livadhia, 7060, Cyprus

Operations Office: 120, Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca, 6031, Cyprus

Company Reg: HE 217340
EU VAT Number: CY10217340J
ISO 9001:2015: No. QS.21.038

International Phone: +357 2425 0808

Solutions

Load Balancing

IT As a Service

iGaming

Forex

Migration Services

Security

Disaster Recovery