Question

How to set up multiple https domains for single IP with NodeJS?

Posted September 15, 2021 68 views
Node.jsDigitalOcean Droplets

Let’s say my domains are:

https://abc.com
https://abc.net
https://abc123.com

I want all of them to go to the same IP address (Droplet) which is running NodeJS. Basically, the three web sites all have the same content.

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

You’ll need to configure Nginx as a reverse proxy for that.

What Nginx does is receives traffic on port 80 and 443 for your domains and depending on their Nginx configuration, redirects them internally to a specified port on which NodeJS is listening.

That’s the basis of it, I know it doesn’t let you know how to configure it actually but this is what the next tutorial is for:

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

Check it out, it helps with installing NodeJS, PM2, configuring and installing Nginx as a reverse proxy server.

You can follow Step 4 of the tutorial multiple times( the configuration part) for your 3 domains. The only thing I would suggest is to change the internal port your Nginx will be redirecting for each domain.

Regards,
KFSys

by Lisa Tagliaferri
by Kathleen Juell
Node.js is an open-source JavaScript runtime environment for building server-side and networking applications. The platform runs on Linux, macOS, FreeBSD, and Windows. Though you can run Node.js applications at the command line, this tutorial will…