Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Still getting 413 Request Entity Too Large even after client_max_body_size 100M

I'm using Rails and Nginx on Digital ocean and I've been trying to upload a 17.6 MB file and I'm still getting 413 Request Entity Too Large even after setting client_max_body_size 100M in my /etc/nginx/nginx.conf file.

Here's the snippet from the file:

http {

  ##
  # Basic Settings
  ##

  client_max_body_size 100M;
  sendfile on;
  tcp_nopush on;
  ...
}

After setting this I've used sudo service nginx reload. When that didn't work I've even done a full reboot using sudo shutdown -r now and then cap production puma:start from my local machine. I've also tried client_max_body_size 0; which, from what I understand should disable checking of file sizes entirely. Nothing works. Plus, in getting to this point, I've made some mistakes in the location of the client_max_body_size statement and in those situations the server has failed to start correctly giving a "Something went wrong" error, so I'm pretty sure the changes I'm making are to the right file.

Is there something I might be missing? Is there another place I'm missing to configure this? Is there something I'm missing in the way I'm currently configuring it? Any pointers would be greatly appreciated.

like image 541
tobogranyte Avatar asked Apr 21 '16 22:04

tobogranyte


1 Answers

Okay. I figured this out. Following the Digital Ocean guide for how to configure nginx, I was setting client_max_body_size 100M in the file /etc/nginx/nginx.conf. And for sure, changing things there definitely had impact on what the server did. Especially when I would mess something up in that file and the server stopped functioning.

However, I had forgotten that in Deploying a Rails App on Ubuntu 14.04 with Capistrano, Nginx, and Puma which was my main resource for setting up my server, it shows that these parameters get set up not in the above nginx.conf but rather in my rails app there is the file ~/my_app/config/nginx.conf in which the setup parameters already included the statement

  client_max_body_size 10M;

So I changed that statement as well as in the /etc/nginx/nginx.conf file on production. Voila! Now I can upload files up to 100M.

like image 131
tobogranyte Avatar answered Oct 05 '22 20:10

tobogranyte