FREE TRIAL

Free VPS Trial

Start Free Trial
  • Live Chat
  • +357 2425 0808
  • Login
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

Categories

Backup
6
Business Continuity
4
Cloud Hosting
9
Colocation
4
Company Updates
1
Cryptocurrencies
1
Data Centers
12
Dedicated Servers
4
Disaster Recovery
3
Forex
24
Gaming
1
iGaming
33
Industry News
31
Interviews
10
Joomla
9
Magento
5
Managed Services
1
Operating Systems
1
Press Releases
60
Product News
6
Resellers
1
Security
24
Software & Apps
1
Streaming
1
Tech Startups
12
Tutorials
56
Uncategorized
389
Vps Hosting
11
Web Design & Development
3
Web Hosting
43
Webinars
1
Wordpress
14

Free VPS Trial

No Credit Card Required.

Recent Posts

Reflecting on a Year of Growth and Big Investment [CEO Interview at SBC Leaders Magazine]

Reflecting on a Year of Growth and Big Investment [CEO Interview at SBC Leaders Magazine]

25 January, 2023

How To Remove SSH Keys from Linux Server

How To Remove SSH Keys from Linux Server

16 January, 2023

How To Install Language Pack on Windows Server 2019

How To Install Language Pack on Windows Server 2019

30 December, 2022

Ultimate Fintech Awards 2023: NetShop ISP Shortlisted for “Best Connectivity Provider – MEA” Award

Ultimate Fintech Awards 2023: NetShop ISP Shortlisted for “Best Connectivity Provider – MEA” Award

29 December, 2022

Updated Version of myNetShop Client Portal Released: What’s New

Updated Version of myNetShop Client Portal Released: What’s New

27 December, 2022

Products

Bare Metal Dedicated Servers

Virtual Servers (VPS / VDS)

Rack Space & Colocation Hosting

Fast Web Hosting

Cloud Backup

Premium DNS Hosting

Resources

Blog

Videos

Events

APIConnect

WhitepapersNew

Looking Glass

Company

About Us

CareersNew

Awards & Honours

Become a hosting Partner of NetShop ISP

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