Question

[Beginner] Subdomain Setup to specific IP:port (sneaky configuration)

Posted February 19, 2021 179 views
ApacheNode.jsDNSControl PanelsReact

Hello everyone! I’m looking forward to receiving support and help from the community!
Here’s the challenge!

Beginner:

To kick it off, I am an extreme beginner at this. so, the more detailed/step-by-step answer you can provide the better for me and any other beginner seeking a similar solution.

Context:

There are three variables for the current issue:

  • I have a domain name registered in a place
  • The root/main domain (naggiar.net) is routed to a hosting server outside Digital OCean
  • However, a developer has created a web app (REACT/NodeJS) and we installed it on Digital ocean on the following IP: http://68.183.218.18:5001

What’s needed:

Here is what we’ve done so far:

  • Created a subdomain shop.naggiar.net
  • Created an A record to point to the IP 68.183.218.18

How can you help?

  • What is/are the next step(s) that we need to do?
  • on which server should they need to be done?

Looking forward to your support and help!
Thanks,

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.

×
Submit an Answer
1 answer

Hi there,

Welcome the DigitalOcean community!

What I could suggest in this case is:

  • As you mentioned add an A record for your subdomain name to point the Droplet’s IP address. After that note that it could take up to a 24/48 hours for the DNS cache to clear over the Globe before you could see the new recrod

  • Then on your server, I would recommend using Nginx as a reverse proxy, so that when you visit your subdomain name in your browser, you don’t have to type the port after that.

To install Nginx you can follow the steps here:

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04

After that you can use the following configuration:

server {
    listen 80;
    server_name your_domain.com;
    root /var/www/html;

    index index.html index.htm index.php;

<^>    location / {
        proxy_pass http://localhost:5001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }<^>

}

For more details on how to setup NodeJS for production, I would recommend this tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

Regards,
Bobby

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.