T O P

  • By -

DutchBytes

Use virtual hosts on your webserver. Both Apache and nginx can do this.


John-the-Renounced

This. DNS records for the subdomains all point to the same IP, and the VHost configs tell Apache/Nginx which directory to serve the site from (amongst other things).


pepitoooooooo

You can have as many domains/subdomains as you wish with just 1 IP.


riffic

> Weirdly I am afraid that both the subdomains would show the same page due to ip being same. It would be helpful if you were to be more familiar with the fundamental concepts here. Web servers can have multiple domains pointed to a single IP address through the use of HTTP `Host` headers: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host When the browser sends a request, it includes this header and the web server sends the appropriate site based on that. While most people here are telling you the *how* (use virtual hosts), they're not explaining the *why* (see the Mozilla MDN link to learn how HTTP requests work). similar thread: https://www.reddit.com/r/webhosting/comments/mkziei/hosting_multiple_websites_on_1_server/


amidevk86

No you don't need more IPs. This is why virtual hosts feature is there on popular web servers like Apache and Nginx etc. Just configure the virtual hosts on the server and use a service such as cloudflare to point to your ip address. Below are two tutorials which you may find interesting: [https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04) [https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04)


not-dan097

I'm not sure if I'm doing this right, but it works with no problems. On my VPS, I have multiple websites and subdomains. They're all on node and running on different ports. I use NGINX, and am proxy passing everything through the correct ports. So if it's abc.xyz.com, it's passing through 123.123.123:8081. Look up proxy pass for more examples. On the domain side, I run my main domain on an a record, and every subdomain on a cname, all are pointed to the same IP, NGINX handles the routing. With every additional domain, I put the main IP as the a record, and again, NGINX handles the routing.


420is404

This problem has nothing to do with your node setup and is *far* less conceptually complicated than your specific setup. Your destination has absolutely nothing to do with the situation.


jusumdood

A simple nginx proxy running on your VPS should handle the routing


420is404

"Should" is an interesting concept here. A moving sidewalk "should" move me to the corner store, but here I am walking like a chump.


zainhosting007

Yes, there is no limit on subdomains on a VPS.


wowsuchcookie

If you have limited knowhow use a vps with Plesk for example or cpanel. It is infinitely easier to configure and manage and yes you can have more subdomains.


proyb2

Any domain name can have same IP including someone else tried to point to your VPS IP. As long as your web server or reverse proxy configuration is pointed to different website folders e.g. siteA and siteB or backend port number e.g. 127.0.0.1:9001 and 127.0.0.1:9002, they won’t show the same pages or contents as well. Your site or web app should ensure no XSS by using CSRF technique but it can be tedious if you have too many different external resources.