How to solve Nginx: 413 Request Entity Too Large error

Updated: 28 July, 2016 seen 18,871

I'm running a Nginx powered server I have configured a while ago. One problem I have on my Drupal sites hosted on that environment is that I couldn't upload a files larger than 1MB using Drupal fields. I got Nginx: 413 Request Entity Too Large error.

And it pissed me of - because of - in my php.ini file I had already set a maximum upload file size to some 192MB.

When I faced a situation, when I had to upload files larger than 1MB, I went on my searches, what's wrong with my server, after 1 minute search I found a solution here:

sudo nano /usr/local/nginx/conf/nginx.conf

add the following line to http section

# set client body size to 2M #
client_max_body_size 2M; 

save and exit

Restart the Nginx server

sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx start