Milano
Milano

Reputation: 18705

Nginx doesn't work as expected (shows default page)(Ubuntu 16.04)

Can't figure out where is the problem with my configuration. I have DigitalOcean VPS where I run Django project. I've configured Gunicorn and Nginx. Set correct IP address. Checked gunicorn status (ok).

No errors in /var/log/nginx/error.log

NGinx is still showing the default page instead of Django project homepage.

Even deleted default from sites-enabled and still see nginx default page.

gunicorn.service

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=django
Group=www-data
WorkingDirectory=/home/django/nameofmyproject
ExecStart=/home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/django/nameofmyproject/nameofmyproject.sock nameofmyproject.wsgi:application

[Install]
WantedBy=multi-user.target

sites-available/nameofmyproject

server {
    listen 80;
    server_name <my_ip_address>;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/django/nameofmyproject;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/django/nameofmyproject/nameofmyproject.sock;
    }
}

gunicorn status

unicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-10-19 09:56:18 UTC; 1min 2s ago
 Main PID: 1372 (gunicorn)
    Tasks: 4
   Memory: 138.0M
      CPU: 3.971s
   CGroup: /system.slice/gunicorn.service
           ├─1372 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work
           ├─1555 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work
           ├─1556 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work
           └─1557 /home/django/nameofmyproject/nameofmyprojectvenv/bin/python /home/django/nameofmyproject/nameofmyprojectvenv/bin/gunicorn --access-logfile - --work

Oct 19 09:56:18 ubuntu-16 systemd[1]: Started gunicorn daemon.
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1372] [INFO] Starting gunicorn 19.7.1
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1372] [INFO] Listening at: unix:/home/django/nameofmyproject/nameofmyproject
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1372] [INFO] Using worker: sync
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1555] [INFO] Booting worker with pid: 1555
Oct 19 09:56:21 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1556] [INFO] Booting worker with pid: 1556
Oct 19 09:56:22 ubuntu-16 gunicorn[1372]: [2017-10-19 09:56:21 +0000] [1557] [INFO] Booting worker with pid: 1557

Really don't know where is the problem. How to debug this?

Upvotes: 0

Views: 776

Answers (1)

Nijo
Nijo

Reputation: 841

Make sure You did the following

  1. create a symbolic link of your nginx conf in sites-available to sites-enabled.
  2. Reload nginx after deleting default conf

Upvotes: 1

Related Questions