I am currently working on a django project which I deployed to a digitalocean droplet with nginx. The website works, including the staticfiles. After looking at my error.log
i saw that it was a permission problem:
2024/04/27 18:58:19 [error] 130139#130139: *194 open() "/home/project/project/media/gallery/IMG_9510.jpeg" failed (13: Permission denied)
And when excecuting the namei
command, this is the response:
root@host:~# namei -l /home/project/project/media/gallery/IMG_9510.jpeg
f: /home/refugium/refugium/media/gallery/IMG_9510.jpeg
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-x--- project_user project_user project
drwxrwxr-x project_user project_user project
drwxr-xr-x www-data www-data media
drwxr-xr-x www-data www-data gallery
-rwxr-xr-x www-data www-data IMG_9510.jpeg
So the permissions seem to be fine.
For the last check I shortly changed the user in my nginx.conf
to root
. After that it worked. Did I miss anything?
This is my file in sites-available
:
server {
listen 80;
server_name refugium-romontberg.ch;
location = /favicon.ico {
access_log off;
log_not_found off;
}
location /media/ {
alias /home/refugium/refugium/media/;
}
location /static/ {
alias /home/refugium/refugium/staticfiles/;
}
location / {
client_max_body_size 200M;
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
Thanks