0
votes

I deployed the server with Ubuntu 18, Django, Gunicorn, Nginx And I ran into this problem:

everything works great but, When I upload large pictures files in Django, Nginx gives 403 Error Forbidden.

I updated the permissions to the folder with static files on 755. It works! But when I upload other files, the rights do not work.

I added the user root and user www-data to the folder owner’s group, but nothing has changed.

I understand that Nginx has no permissions, but how can I implement the inheritance permissions of new files from the parent folder

or will you suggest another solution?

2
have you given permission to media folderrahul.m
yes, recursivelyCoder Bug
try adding this to your settings.py file- FILE_UPLOAD_PERMISSIONS = 0o644Reema Parakh
god damn, yeah! thank you very much!!!! Can you explain where I can see the full list of permissions?Coder Bug
@CoderBug Please check this: docs.djangoproject.com/en/2.1/ref/settings/…. Also sorry for late response, I was travelling :D. I will post this as a answer, Please accept it if this was useful :)Reema Parakh

2 Answers

0
votes

You need to add FILE_UPLOAD_PERMISSIONS=0o644 variable to you settings.py file. This is the numeric mode (i.e. 0o644) to newly uploaded files to.

For more information, please read this doc.

0
votes

Try use this

chown -R www-data:www-data 'your project folder'