I am running a Django application on a Linux server with NGINX.
I am having issues accessing the index.html to load static files such as CSS and JavaScript.
Paths:
Project path: /opt/proj/proj
Static folder path: /opt/proj/proj/static
Static files path: /opt/proj/staticfiles
WSGI path: /opt/proj/proj/config wsgi
HTML templates path: /opt/proj/proj/login/templates
Settings.py:
BASE_DIR: /opt/proj/proj
STATIC_ROOT: /opt/proj/staticfiles
STATICFILES_DIRS: ['/opt/proj/proj/static']
ls -la:
drwxrwxr-x 6 appusr root 4096 Sep 10 11:00 .
drwxrwxr-x 3 appusr appusr 4096 Sep 9 22:44 ..
drwxrwxr-x 2 appusr root 4096 Sep 10 08:53 bin
drwxrwxr-x 3 appusr root 4096 Sep 9 22:44 lib
drwx------ 6 appusr appusr 4096 Sep 10 11:04 proj
-rwxrwxr-x 1 appusr root 203 Sep 10 08:53 pyvenv.cfg
drwxr-xr-x 6 www-data www-data 4096 Sep 10 11:00 staticfiles
NGINX Configuration:
server {
listen 80;
server_name pense.ai;
access_log /var/log/nginx/proj.log;
location /static/ {
alias /opt/proj/staticfiles/;
}
location / {
proxy_pass http://181.177.55.120:8000;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALLDSP COR PSAa PSDa OURNOR ONL UNI COM NAV"';
}
}
Console Error:
WARNING 2024-09-10 13:29:08,648 log Not Found: /static/css/login-btn-voltar.css
Not Found: /static/css/login-style.css
WARNING 2024-09-10 13:29:08,653 log Not Found: /static/css/login-style.css
Not Found: /static/js/login.js
WARNING 2024-09-10 13:29:08,665 log Not Found: /static/js/login.js
I have literally tried everything. I am almost considering removing the CSS, JS, and image files from the static folder and placing them directly in the project directory since the pages load fine… Does anyone know how to resolve this?
I have tried changing the NGINX configuration, adjusting folder locations, modifying permissions, changing directory ownership, running python manage.py collectstatic, and verifying the file paths multiple times…
3