DEV Community

Mohamed Sameer
Mohamed Sameer

Posted on • Edited on

3 1

Connecting my domain name on digital ocean droplet

Hey guys!

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;
   }
  }
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay