Nginx не получает доступ к папкам внутри папки static (приложение django)
Я искал и не нашел этой точной проблемы.
Я развернул приложение на django на GCP, используя gunicorn + nginx
Все работает нормально, за исключением статических файлов
Я запустил django's collectstatic и получил папку files и статику в таком виде:
lnmat@sistema-ag:~/app_repo$ ls
apps gunicorn-error-log requirements.txt static venv
base_static manage.py sistema_vendas_ag templates
lnmat@sistema-ag:~/app_repo$ cd static
lnmat@sistema-ag:~/app_repo/static$ ls
admin global
lnmat@sistema-ag:~/app_repo/static$ ls admin
css fonts img js
lnmat@sistema-ag:~/app_repo/static$ ls global
css js vendor
В журнале ошибок nginx:
2022/12/13 20:36:00 [error] 8136#8136: *1 open() "/home/lnmat/app_repo/static/js/sb-admin-2.min.js" failed (2: No such file or directory), client: x.x.x.x, server: -, request: "GET /static/js/sb-admin-2.min.js HTTP/1.1", host: "x.x.x.x", referrer: "http://x.x.x.x/login/?next=/"
2022/12/13 20:36:09 [error] 8136#8136: *7 open() "/home/lnmat/app_repo/static/css/sb-admin-2.min.css" failed (2: No such file or directory), client: x.x.x.x, server: -, request: "GET /static/css/sb-admin-2.min.css HTTP/1.1", host: "x.x.x.x", referrer: "http://x.x.x.x/"
2022/12/13 20:36:09 [error] 8136#8136: *12 open() "/home/lnmat/app_repo/static/vendor/jquery/jquery.min.js" failed (2: No such file or directory), client: x.x.x.x, server: -, request: "GET /static/vendor/jquery/jquery.min.js HTTP/1.1", host: "x.x.x.x", referrer: "http://x.x.x.x/"
Очевидно, nginx пытается получить доступ к статическим файлам непосредственно в главной папке, не обращаясь к подпапкам global/ и admin/, где и находятся файлы.
Блок моего сервера nginx:
server {
listen 80;
server_name x.x.x.x;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
location /static/ {
autoindex on;
alias /home/lnmat/app_repo/static/;
}
}
Мой settings.py:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
BASE_DIR / 'base_static',
]
STATIC_ROOT = BASE_DIR / 'static/'
Я не знаю, что это может быть, есть предложения?
[EDIT]
Мои статические теги в шаблоне:
{% load static %}
...
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link href="{% static 'vendor/fontawesome-free/css/all.min.css' %}" rel="stylesheet" type="text/css">
...
Моя папка base_static: image