Проблема разрешения статических файлов Django на nginx

Я хочу развернуть свой проект Django на linux vps, но у меня есть проблема, и проблема в том, что мой nginx отказывает в разрешении на открытие статических файлов, я обнаружил эту ошибку в файле error.log:

 open() "/home/sam/testdjango/static/admin/js/nav_sidebar.js" failed (13: Permission denied>)

вот мой файл nginx.conf:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/jav>
        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

N/B: пользователь, который вошел в систему, - 'sam'.

и это мой nginx sites-available:

server {
    listen 80;
    server_name 185.8.174.180;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/sam/testdjango;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;

    }
}

Мой пользователь в службах gunicorn: 'sam' и группа: 'www-data' Разрешения для моих каталогов:

total 140
-rw-r--r-- 1 sam sam      131072 Apr 25 21:54 db.sqlite3
-rwxrwxr-x 1 sam sam         666 Apr 25 11:11 manage.py
drwxrwxrwx 3 sam www-data   4096 Apr 25 13:16 static (this is my statics` directory) i think its 777 code
drwxrwxr-x 3 sam sam        4096 Apr 25 21:05 testdjango

если я не ошибаюсь, это было все, я буду благодарен, если вы, ребята, помочь мне, Ty <3

You have to grant permission to all files, but there is also a better way of managing static files. In django settings you can specify STATIC_ROOT and STATICFILES_DIRS. Firs is a location when you want to store your static files. It is good to put it inside the /var/www/html directory since nginx should be able to access this directory. In STATICFILES_DIRS you specify all directories where you have your static files. You have to also change then static file location in your nginx config. In your case it would be sth like this

location /static/ {
    root /var/www/html;
}

and in your settings file you should add this:

STATIC_ROOT = "/var/www/html"
STATICFILES_DIRS  =[put there all directories with static files from root]
Вернуться на верх