Can I have two different domains point to same loader, but load different websites?

March 6, 2019 523 views
Load Balancing

So I have a main loader called:

kog-game-loader which uses a certificate

I want:
thidomain.org to run one http server and
test.thisdomain.org to run another

Both of them going through the same loader and having a certificate.

EDIT: Sorry, the servers would run on two different droplets as well.

Is this possible?

3 Answers

Hey friend,

This is fine but you would need a virtual host (Apache) / server block (Nginx) on each server that routes the traffic for the requested website. You can do this:

- Load Balancer
-- Droplet 1
---- Site 1
---- Site 2
-- Droplet 2
---- Site 1
---- Site 2

But you can’t do this reasonably:

- Load Balancer
-- Droplet 1
---- Site 1
-- Droplet 2
---- Site 2

These may help you in configuring the web server for it:

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Jarland

by Brennen Bearnes
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 16.04 server.

I don’t use apache nor nginx, I just use straight up Node.js

Hello, @jarland.

You say I can route 2 different domains through 1 loadbalancer?
I don’t think you can do that..

What I wanted is:
web.xxx.com:443 -> loadbalancer (with SSL termination) -> droplet-1:80
api.xxx.com:443 -> loadbalancer (with SSL termination) -> droplet-1:80

The thing is that it doesn’t let me have 2 rules with the same port.
I can only understand this if the routing is done in layer 4, but if routing is done in layer 7 (which is HTTP layer), it should be able to map the domain names to the correct rules.

Have another answer? Share your knowledge.