How to config nginx for multiple nodejs apps?

November 30, 2019 91 views
Nginx

i just config nginx like this

  server {
    listen 80;
    server_name mydomain.com www.mydomain.com;
    location / {
      proxy_pass http://167.172.192.169:7000;
      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;
    }
  }
server {
  listen 80;
  server_name app.mydomain.com;
  location / {
    proxy_pass http://167.172.192.169:38453;
    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;
  }
}

i want sudomain app run in other node app
but i still get stuck here, did i need config and DNS ???
pls help

edited by aha
1 Answer

Hello,

Yes indeed you are correct, you would still need to set up an A record for your subdomain name to point to your droplet’s IP address.

If you are using DigitalOcean’s Nameservers, you could take a look at this tutorial on how to setup DNS records:

https://www.digitalocean.com/docs/networking/dns/how-to/manage-records/

Once you make the change, it can take up to 48 hours for the DNS cache to clear over the Globe before you could see the changes.

Regards,
Bobby

Have another answer? Share your knowledge.

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