Connecting my domain name on digital ocean droplet
Asked Answered
F

3

6

I created a small hello world node app, then i hosted the app on digital ocean droplet, after that i can access my application on http://my_public_ip:3000

Felt happy 😍

Then i bought a domain name called helloworld.tk free domain from freenom.com After that i install nginx as a webserver in my droplet then i added a reverse proxy code in /etc/nginx/sites-enable/default

My code looks like:

   server {
   listen 80;
   server_name helloworld.tk

   location / {
    proxy_pass http://localhost:3000;
   }
  }

After that i went to domain management panel in my freenom.com and set url forwarding to http://my_public_ip

So if i enter my domain name helloworld.tk in browser my node app successfully works 🀩 but wait what πŸ€” my ip address is showing on left side below corner on chrome and if i refresh the page multiple times i get

   402 Too many request error page on nginx

So i deleted my url forwarding and in my domain management panel instead of url forwarding i set my nameservers like this ns1.digitalocean.com bla.bla.bla...

Then i added my domain in my digitalocean panel. Now yes everything is working perfect.

If i hit my url no ip address is showing, also no too many request errors 😌

My node app successfully getting executed!

Wait i am a beginner for hosting node app, so i need help whether it is correct good setup for nodeapp on production?

What is the difference between url forwarding and nameservers? Whether my nginx reverse proxy code is correct? is my reverse proxy working correctly?

NOTE: I used pm2 for running node app on background.

Feld answered 29/9, 2018 at 14:19 Comment(0)
S
11

First, remove the forwarding and you need to change the nameservers of the domain in your domain DNS management if your domain is somewhere other than DigitalOcean

Add below nameservers:

ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com

Now check if they are propagating by using whatsmydns.net (Enter your IP and change click on A and select NS and click Search)

Once they are propagating, add the domain to your DigitalOcean account.

Go to your DigitalOcean Dashboard and click on Networking.

Add a domain and click Save.

Then Edit the domain and add the Droplet to the Domain and save.

Now click on the domain name and an A record which points to your droplet.

Hope this will resolve your issue.

Sepulcher answered 4/10, 2018 at 11:37 Comment(1)
I did this exactly, and also find this is the correct approach, thanks for figuring out. – Feld
C
1

Go back to your DNS domain registrar ( freenom.com ) and remove mention of digitalocean nameservers and put back its own default frenom.com nameservers ... also on freenom.com assure you have defined a Type A record to point to your machine's external IP address

Your nginx config looks OK

this should work ... now had you defined digitalocean nameservers in your freecon.com registrar you would have then needed to go to https://cloud.digitalocean.com/networking/ and set up your Type A record there ... its critical to know the location of your nameservers determines where your Type A record must live

Cult answered 29/9, 2018 at 14:50 Comment(0)
Q
1

What you have to do is create a droplet in DigitalOcean and then add your domain name to the droplet in the Networking tab. You have to add both the non-www and www versions so the domain will be pointed correctly. You have to set the A records for those two to the IP of the droplet that DigitalOcean assigned to it.

Then from your GoDaddy/your domain manager, you have to go to ManageDNS and change the default GoDaddy name servers with those of DigitalOcean. Save it and you are done.

Wait for up to 24 hours and test the domain with check-host.net If all done correctly the domain should point to the servers of DigitalOcean in the city you have selected.

Qianaqibla answered 31/10, 2019 at 6:54 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.