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

橙三吉。 提交于 2020-01-02 02:44:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/36781508/still-getting-413-request-entity-too-large-even-after-client-max-body-size-100m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!