Django won't load images, css, favicon 403 Forbidden nginx/1.18.0 (Ubuntu)

Viewed 67

I'm just starting to learn and I don't understand what exactly I'm doing wrong, so sorry for the stupid (probably) question. Block: django + gunicorn + nginx + supervisor Faced the following error after uploading the project to Ubuntu server. All images, css, and even favicons don't work. The browser gives them an error 403 Forbidden nginx/1.18.0 (Ubuntu).

here is what is in the default file from Nginx

server {

    server_name dbms_template_web_address;

    location /.well-known {
    root /var/www/html;
    }

    location = /favicon.ico {
        alias dbms_template_path/djangowebsite/static/favicon.ico;
    }
    location /static/ {
        root dbms_template_path/djangowebsite;
    }
    location /media/ {
        root dbms_template_path/djangowebsite;
    }
    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
        add_header Access-Control-Allow-Origin *;
    }

}

The paths are correct, the files are in working condition and on the server. Settings.py:

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "config/static/")
]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

Html will not show. after all, the home project on the network 127.0.0.1:8000 works correctly and displays everything correctly too.

debag = False

please, please, please help me. the third day already I conjure. lost all hope. Reinstallation of the complete project did not give any result.

0 Answers
Related