0

I am trying to follow the https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 guide

This is the nginx in /etc/nginx/sites-enabled

   server {
        listen 80;

    server_name narsil.mti.local;

    location = /favicon.ico { access_log off; log_not_found off; }
    location ^~ /static/ {
        root /home/rohan/Desktop/narsil/narsil/;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/rohan/Desktop/narsil/narsil.sock;
    }
}

This is the gunicorn.service in /etc/systemd/system

[Unit]
Description="Gunicorn application server handling narsil"
After=network.target
[Service]
User = root
Group = www-data
WorkingDirectory = /home/rohan/Desktop/narsil/
ExecStart = /home/rohan/Desktop/narsil/narsilenv/bin/gunicorn --access-logfile - --workers 10 --bind unix:/home/rohan/Desktop/narsil/narsil.sock narsil.wsgi:application

[Install]
WantedBy=multi-user.target

The address narsil.mti.local has been set for the IP address of this Virtual Machine which is at 192.168.45.171

When I go to http://192.168.45.171/admin I get nginx 404 error. At 192.168.45.171 I am able to see the apache home page. I can confirm that the static files are all there and I have given chmod 777 permissions to that folder(Probably not safe, still)

The nginx process log has no errors

Jun 27 08:44:31 rohan-VirtualBox systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 27 08:44:31 rohan-VirtualBox systemd[1]: Started A high performance web server and a reverse proxy server.

The access log seems fine too

127.0.0.1 - - [27/Jun/2018:08:45:04 -0600] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
127.0.0.1 - - [27/Jun/2018:08:45:05 -0600] "GET /icons/ubuntu-logo.png HTTP/1.1" 404 152 "http://127.0.0.1/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
127.0.0.1 - - [27/Jun/2018:08:45:05 -0600] "GET /favicon.ico HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:20 -0600] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:20 -0600] "GET /icons/ubuntu-logo.png HTTP/1.1" 404 152 "http://192.168.45.171/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:20 -0600] "GET /favicon.ico HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:25 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:48:27 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:48:59 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:49:00 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:58:16 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

The error nginx log is blank so no errors there

Gunicorn logs looks good too

127.0.0.1 - - [27/Jun/2018:08:45:04 -0600] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
127.0.0.1 - - [27/Jun/2018:08:45:05 -0600] "GET /icons/ubuntu-logo.png HTTP/1.1" 404 152 "http://127.0.0.1/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
127.0.0.1 - - [27/Jun/2018:08:45:05 -0600] "GET /favicon.ico HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:20 -0600] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:20 -0600] "GET /icons/ubuntu-logo.png HTTP/1.1" 404 152 "http://192.168.45.171/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:20 -0600] "GET /favicon.ico HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:45:25 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:48:27 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:48:59 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:49:00 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
192.168.45.171 - - [27/Jun/2018:08:58:16 -0600] "GET /admin HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

Anyone's got any idea for the 404 error? The project runs fine when I do python manage.py runserver if that helps. I tried following the answers given for similar questions here but I drew a blank

  • If the request is received by Django, it's the wrong Django configuration. Can you share the settings module you're using? Other than that, 1. does appending slash (e.g. /admin/ instead of /admin change something? 2. do you have django.contrib.admin in INSTALLED_APPS? – hoefling Jul 6 '18 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.