Nginx Increase File Upload Size

By default in our nginx configuration the file upload size limit is 1 MB and here we will in Nginx Increase File Upload Size.

Nginx Increase File Upload Size

Open Nginx Configuration file

sudo nano /etc/nginx/nginx.conf

Update client_max_body_size

If you want to increase the limit for all server blocks then simply update client_max_body_size as given below.

http {
    client_max_body_size 50M;
}

If you want to increase the limit for specific directories then simply update client_max_body_size as given below.

location /uploads {
    client_max_body_size 50M;
}

If you want to increase the limit for specific website then simply update client_max_body_size as given below.

server {
    client_max_body_size 50M;
}

M stands for MB.

Restart Nginx

Use command below to restart Nginx

sudo systemctl restart nginx 

or 

sudo /etc/init.d/nginx reload

If you do not want to restart nginx then simply reload Nginx using the command given below.

sudo nginx -s reload

For more code examples click hereNginx documentation here