Nginx django static не может полностью обслужить мои файлы(403 permission denied)

Я имею дело с nginx около 1 недели. У меня есть 4 сервиса, которые я настроил с помощью docker, django postgresql fastapi и nginx, но nginx не обслуживает статические файлы django. Я сталкиваюсь с ошибкой 403. Я пробовал решения всех подобных полей ошибки, но это не работает (разрешение на файл предоставление контроля пути к файлу) ниже я делюсь файлами, которые я использую, пожалуйста, помогите.

docker-compose.yml:

  django_gunicorn:
    build: .
    command: gunicorn sunucu.wsgi:application --bind 0.0.0.0:7800 --workers 3
    volumes:
      - ./static:/root/Kodlar/kodlar/static
    env_file:
      - .env
    environment:
      - DATABASE_URL="**"
    ports:
      - "7800"
    depends_on:
      - db
  nginx:
    build: ./nginx
    volumes:
      - ./static:/root/Kodlar/kodlar/static
    ports:
      - "80:80"
    depends_on:
      - django_gunicorn

volumes:
  static_files:

Django Docker File:

FROM python:3.8-slim-buster

WORKDIR /app

ENV PYTHONUNBUFFERED=1

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

COPY . .

RUN python manage.py migrate --no-input
RUN python manage.py collectstatic --no-input
CMD ["gunicorn", "server.wsgi:application", "--bind", "0.0.0.0:7800","--workers","3"]

Django Settings py:

STATIC_URL = '/static/'
STATIC_ROOT = '/root/Kodlar/kodlar/static/'

Nginx Docker File:

FROM nginx:1.19.0-alpine

COPY ./default.conf /etc/nginx/conf.d/default.conf

Nginx Conf File:

upstream django {
    server django_gunicorn:7800;
}

server {
    listen 80;
    server_name mydomain.com;

    error_page 404 /404.html;
    location = /404.html {
        root /root/Kodlar/kodlar/templates;
        internal;
    }

    if ($host != 'mydomain.com') {
            return 404;
    }

    location / {
        proxy_pass http://django;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /static/ {
        alias /root/Kodlar/kodlar/static/;
    }
    
}

Я хочу, чтобы мой сервис django активно работал с gunicorn и обслуживал статические файлы в nginx

Вернуться на верх