Question

How to config nginx for multiple nodejs apps?

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


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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