NEW VPS PLANS

Experience Ultra-high Performance of NVMe Storage on New UK VPS Plans.

Deploy Instantly
  • +357 2425 0808
  • Login
  • English

Home

Blog

How To Increase File Upload Size in Ngin...

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 · Technical 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

Press Releases
72

Free VPS Trial

No Credit Card Required.

Recent Posts

How To Migrate from MongoDB Atlas to self-hosted Ubuntu 22.04 Server

How To Migrate from MongoDB Atlas to self-hosted Ubuntu 22.04 Server

15 April, 2024

How NetShop ISP Improves Trading Infrastructure Resilience through Equinix LD7 Data Center Hosting

How NetShop ISP Improves Trading Infrastructure Resilience through Equinix LD7 Data Center Hosting

21 March, 2024

Introducing New Cutting-Edge VPS Plans: OKTAPLUS, HYPER, and TITAN Enhanced with NVMe Technology

Introducing New Cutting-Edge VPS Plans: OKTAPLUS, HYPER, and TITAN Enhanced with NVMe Technology

12 March, 2024

How To Install Let’s Encrypt SSL on Ubuntu Server 22.04 for Apache or Nginx

How To Install Let’s Encrypt SSL on Ubuntu Server 22.04 for Apache or Nginx

04 March, 2024

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

23 February, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

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

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer