Set up nginx with multiple domains and node process

Posted August 21, 2020 2.4k views
NginxNode.jsInitial Server Setup

As I was following this tutorial:

It doesn’t seem to work, as when i completed all steps and went to the sub domain it says this site cannot be reached, but if i just go to the ip it just shows this:

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 @selll,

I would recommend following the steps from this tutorial here instead:

Then once you want to start a second Node.js application keep the following things in mind:

  • Make sure that you use a different port for each application
  • Make a copy of the /etc/nginx/sites-available/default to /etc/nginx/sites-available/example2.conf and adjust the values there to match your second application
  • Then enable the second site:
  • ln -s /etc/nginx/sites-available/example2.conf /etc/nginx/sites-example/example2.conf

Finally, restart Nginx as explained in the tutorial.

Let me know how it goes.

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.