I'm trying to set up a domain name to my digital ocean’s droplet. While the IP address works perfectly, the domain name doesn’t seem to do anything and get “This site can’t be reached”.
Checking https://whois.net/ it shows the DNS nameservers are pointing to right direction which are digital ocean’s name servers [NS1.DIGITALOCEAN.COM, NS2.DIGITALOCEAN.COM, NS3.DIGITALOCEAN.COM], and using www.whatsmydns.net it shows the domain name has propagated.
Digital Ocean’s DNS records are the following:
A--domain.tk--directs to X.X.X.X
CNAME--www.domain.tk is an alias of domain.tk
NS--domain.tk--directs to ns1.digtalocean.com
NS--domain.tk--directs to ns2.digtalocean.com
NS--domain.tk--directs to ns3.digtalocean.com
I’m using a .tk domain using freenom and have configured the same domain nameservers over there.
My NGINX configuration is the following:
upstream jaciv_server {
server djangoapp:8000;
}
server {
listen 80;
server_name domain.tk www.domain.tk;
location / {
proxy_pass http://jaciv_server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /opt/services/djangoapp/static/;
}
location /media/ {
alias /opt/services/djangoapp/media/;
}
}
My docker-compose.yml is the following
version: '3'
services:
djangoapp:
build: .
volumes:
- .:/opt/services/djangoapp/src
- static_volume:/opt/services/djangoapp/static
- media_volume:/opt/services/djangoapp/media
domainname: jaciv.tk
networks:
- nginx_network
- database1_network
depends_on:
- database1
nginx:
image: nginx:1.13
ports:
- 8000:80
volumes:
- ./config/nginx/conf.d:/etc/nginx/conf.d
- static_volume:/opt/services/djangoapp/static
- media_volume:/opt/services/djangoapp/media
depends_on:
- djangoapp
- redis
networks:
- nginx_network
database1:
image: postgres:10
networks:
- database1_network
volumes:
- database1_volume:/var/lib/postgresql/data
redis:
image: "redis:alpine"
networks:
- database1_network
- nginx_network
celery:
build: .
command: celery -A jaciv_app worker -l info
volumes:
- .:/opt/services/djangoapp/src
depends_on:
- database1
- redis
- djangoapp
networks:
- database1_network
celery-beat:
build: .
command: celery -A jaciv_app beat -l info
volumes:
- .:/opt/services/djangoapp/src
depends_on:
- database1
- redis
- djangoapp
networks:
- database1_network
- nginx_network
networks:
nginx_network:
driver: bridge
database1_network:
driver: bridge
volumes:
database1_volume:
static_volume:
media_volume:
My allowed hosts is django setting
ALLOWED_HOSTS = ['domain.tk', 'X.X.X.X']