penlightment
penlightment

Reputation: 71

Nginx 403 Forbidden on serving large images

I have setup a Django application, in which user can upload his image and it is served by Nginx and Gunicorn.

I have a problem with uploading large image files which does not get appropriate permissions to be served by Nginx

location /medias/images/ {
        root /var/www/html;
}

When uploading files, the larger ones only get read permissions for the user, not for group/other:

-rw-------  1 user1 user1 4.9M Mar 15 14:35 File1.jpg
-rw-------  1 user1 user1 3.7M Mar 15 14:31 File2.jpg
-rw-r--r--  1 user1 user1 110K Mar 15 14:44 File3.pdf
-rw-r--r--  1 user1 user1  34K Mar 15 09:17 File4.docx
-rw-r--r--  1 user1 user1 136K Mar 15 14:45 File5.jpg
-rw-r--r--  1 user1 user1  92K Mar 15 14:22 File6.doc
-rw-------  1 user1 user1 4.4M Mar 15 14:25 File7.jpg

However the smaller images get their permissions fine and are served properly.

The point is that both uploading small and semi-large (3mb) image files are done by a same process.

Any ideas?

Upvotes: 2

Views: 917

Answers (1)

Lorer
Lorer

Reputation: 31

Set the FILE_UPLOAD_MAX_MEMORY_SIZE parameter in your Django settings, in Bytes.

For example FILE_UPLOAD_MAX_MEMORY_SIZE = 20971520 equals 20MB.

Upvotes: 3

Related Questions