Question

Setting up Domain on DigitalOcean to Django & Nginx

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.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
November 3, 2020
Accepted 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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel