Nginx:413实体太大-文件无法到达应用程序

rak*_*esh 5 wsgi nginx uwsgi python-2.7

我使用Nginxuwsgi用WSGI应用程序。当我尝试上传图像时,有时应用程序无法获取图像,并且曾经有错误413 entity too large

我通过添加解决了这个问题client_max_body_size 4M;,我的Nginx配置文件看起来像:

//Add sample Nginx Server
//Block here
Run Code Online (Sandbox Code Playgroud)

错误停止显示,但文件仍未到达应用程序。我不知道它在某些计算机上可以工作,在某些计算机上也可以工作。

ajt*_*rds 5

如果尝试上传413 Request Entity Too Large错误,则需要增加nginx.conf或任何其他配置文件中的大小限制。client_max_body_size xxM在服务器部分内添加xx,您要允许的大小(以兆字节为单位)在哪里。

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        client_max_body_size 20M;
        listen       80;
        server_name  localhost;

        # Main location
        location / {
            proxy_pass         http://127.0.0.1:8000/;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)


小智 1

这意味着最大文件大小大于上传大小。请参阅client_max_body_size

所以尝试使用而不是使用固定值。

server {
     [...]
     client_max_body_size 0;
     [...]
}
Run Code Online (Sandbox Code Playgroud)

值为 0 将禁用最大上传检查,但我建议设置一个固定值,例如3M10M等...。