Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use the same node.js server for two/three different domains (aliases)?

Is it possible to use the same nodeJS server for two/three different domains (aliases)? (I don't want to redirect my users. I want them to see the exact URL they typed in the address bar. However, all three domains are exactly the same!)

I want my users to be logged in on all three domains at the same time, in order to avoid any confusion.

What is the simplest way to do this and avoid cross-domain issues?

Thanks!

like image 306
Emilio Avatar asked Nov 06 '25 16:11

Emilio


1 Answers

If you mean that all domains will serve the same nodejs app then Yes you can do that.

but if each domain should open a different application then you must have a reverse proxy running on the server to handle and manage the sites/vhosts.

You may install nginx and use it as reverse proxy server or look for http-proxy a library for nodejs.

If you would like to manage the vhosts in your app you can look for vhost middleware for nodejs and use it

like image 62
Ibrahiem Jabareen Avatar answered Nov 08 '25 15:11

Ibrahiem Jabareen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!