File size upload in nginx.conf

How to increase or decrease the file size upload in Nginx web server using nginx.conf

By default, Nginx web server has a default upload limit of 1MB for files.

To increase or decrease this limit you need to change the client_max_body_size parameter in the nginx.conf configuration file.

Increase file size upload in nginx.conf

Prerequisites

  • Root access to the web server to update the nginx.conf file.

Instructions

  1. Log into your web server via SSH.

  2. Edit the nginx.conf file:

     vi /etc/nginx/nginx.conf
  3. Find the client_max_body_size parameter. It should be in the server {} block directive:

     server {
        client_max_body_size 8M; # 8M is 8Mb
     
        # other lines
     }

    Replace 8M with the maximum file limit you want to set.

  4. Save the nginx.conf file.

  5. Reload the configuration file to test it:

     sudo nginx -t
  6. Restart Nginx:

     sudo systemctl restart nginx