skip to Main Content

when I don’t specify my port number in my url, static files are not loaded in that case.
It works fine for xyz.com:8000 all the static files are loaded But when i use xyz.com, it doesn’t load any static files.
I’m using nginx server.

this is my nginx configuration

server {
    listen 80;
    server_name santhals.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
    root /home/ubuntu/santhals/myapp/;
}


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

2

Answers


  1. refer this may help?

    Nginx serve static file and got 403 forbidden

    I peeked into your work (sorry but I couldn’t help it) and browser said 403 forbidden.

    Login or Signup to reply.
  2. Your Nginx configs look fine and if there are no permission and access issues, it should work.

    A few things to check:

    1. Make sure django.contrib.staticfiles is included in the INSTALLED_APPS in your settings.py file.
    2. Make sure STATIC_URL and STATIC_ROOT variables are properly set in your settings.py file. Generally, they should be pointing to the static directory that is located in the root of your project.
    3. Make sure you run python manage.py collectstatic before deploying your application
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search