Error: client must send too large body

I am using django-resto to upload my media files to a remote server. However, when I tried to download, it gives me django_resto.storage: Failed on create .

And the log generated below the posts,

 open() "/var/www/media/media/events/video/clipcanvas_14348_H264_640x360.mp4" failed (2: No such file or directory), client: 172.17.42.1, server: , request: "HEAD /media/events/video/clipcanvas.mp4 HTTP/1.1", host: "IP:8081" client intended to send too large body: body: 2139606 bytes, client: *.*.*.*, server: , request: "PUT /media/events/video/clipcanvas.mp4 HTTP/1.1", host: "IP:8081" 

Can someone explain why I get such an error?

Settings for Media Server,

 DEFAULT_FILE_STORAGE = 'django_resto.storage.DistributedStorage' RESTO_MEDIA_HOSTS = ['IP:8081'] 

Nginx configuration,

 server { listen 192.168.0.10; location / { root /var/www/media; dav_methods PUT DELETE; create_full_put_path on; dav_access user:rw group:r all:r; allow 192.168.0.1/24; deny all; } } 
+6
source share
1 answer

This problem will be caused by nginxs with a low default client_max_body_size (1 MB).

You will need to set client_max_body_size <value> to something more in one of the following context blocks:

  • HTTP
  • a place
  • Server

The code would be something like this:

 server { # set the max body size across the site to be 20mb client_max_body_size 20m; } 

Personally, I would put client_max_body_size in the location block. This means that your new maximum body size will not be set globally and instead is configured for a specific additional location of your website.

 server { # site default is 1mb client_max_body_size 1m; location /user/profiles/upload { # profile images should be no more than 2m client_max_body_size 5m; # the rest of your website will still use 1m max body size } } 

note: Remember that you need to reload the configuration file before the changes affect.

also note:. You can only make client_max_body_size value you need and a little bit. Stops people who could potentially send huge files trying to damage your server.

+17
source

Source: https://habr.com/ru/post/988005/


All Articles