Question

Setting up Domain on DigitalOcean to Django & Nginx

Posted November 3, 2020 107 views
NginxDjango

Finishing up site migration, I’ve been able to get it running on the droplet IP I’ve also checked if IP propagation is complete

enter image description here

and I’ve added the domain to digitalocean

enter image description here

When I try the domain I get This site can’t be reached. I’ve tried to set up the nginx file to match this

server {
    listen 80;
    server_name http://safariguides.org 162.243.173.84 safariguides.org;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/sammy/webapps/kpsga;
    }
    location /media/ {
        root /home/sammy/webapps/kpsga;
    }

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

and in the settings file

DEBUG = True

ALLOWED_HOSTS = [
    'http://safariguides.org',
    'http://162.243.173.84/',
    '*'
]

finally adding the * for maximum matches.

checking for errors in nginx logs shows this

sammy@kpsga:~/webapps/kpsga/kpsga$ sudo tail -F /var/log/nginx/error.log
2020/11/03 06:55:50 [warn] 70740#70740: server name "http://safariguides.org" has suspicious symbols in /etc/nginx/sites-enabled/kpsga:3
2020/11/03 07:00:36 [alert] 70778#70778: *14 open socket #16 left in connection 9
2020/11/03 07:00:36 [alert] 70778#70778: *15 open socket #17 left in connection 10
2020/11/03 07:00:36 [alert] 70778#70778: aborting
2020/11/03 07:00:36 [warn] 70858#70858: server name "http://safariguides.org" has suspicious symbols in /etc/nginx/sites-enabled/kpsga:3
2020/11/03 07:00:36 [warn] 70869#70869: server name "http://safariguides.org" has suspicious symbols in /etc/nginx/sites-enabled/kpsga:3
2020/11/03 07:04:34 [warn] 70893#70893: server name "http://safariguides.org" has suspicious symbols in /etc/nginx/sites-enabled/kpsga:3
2020/11/03 07:04:34 [warn] 70905#70905: server name "http://safariguides.org" has suspicious symbols in /etc/nginx/sites-enabled/kpsga:3
2020/11/03 07:08:24 [error] 70907#70907: *5 open() "/home/sammy/webapps/kpsga/media/wp-includes/wlwmanifest.xml" failed (2: No such file or directory), client: 128.199.240.166, server: http://safariguides.org, request: "GET /media/wp-includes/wlwmanifest.xml HTTP/1.1", host: "safariguides.org"
2020/11/03 07:08:24 [error] 70907#70907: *7 open() "/home/sammy/webapps/kpsga/media/wp-includes/wlwmanifest.xml" failed (2: No such file or directory), client: 128.199.240.166, server: http://safariguides.org, request: "GET /media/wp-includes/wlwmanifest.xml HTTP/1.1", host: "safariguides.org"

the error for a charachter i suspect is from http:\\ before sending this I removed it, restarted nginx but still the domain doesn’t register.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi there @muirurisamuel,

Indeed your DNS looks all good.

At the moment your site is accessible via port 80 (HTTP), however, it does not work over port 443 which is https.

To fix that you need to install an SSL certificate, you can follow the steps here on how to do that:

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04

Regards,
Bobby

by Hazel Virdó
by Kathleen Juell
In this tutorial, we will show you how to use Let's Encrypt to obtain a free SSL certificate and use it with Nginx on Ubuntu 18.04. We will also show you how to automatically renew your SSL certificate. If you're running a different web server, simply follow your web server's documentation to learn how to use the certificate with your setup.
Submit an Answer