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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With