Question

One Load Balancer Per Domain?

I am pretty sure I know the answer, but I can only load balance a single domain name on a DO loadbalancer?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

Multiple domains could potentially be pointed at one load balancer instance. Though there is only one IP address per load balancer. That means that the Droplets behind the load balancer will each need to be able to understand how to respond based on the domain being requested.

A simple example of this would be two static sites being served by Nginx. Each Droplet behind the load balancer would need to serve both sites and Nginx would need to use named server blocks to know which site to serve for which request. A minimal example of what that would look like:

server {
        listen 80 default_server;
        server_name example.com;
        root /var/www/html;
        index index.html;

        location / {
                try_files $uri $uri/ =404;
        }
}

server {
        listen 80;
        server_name blog.example.com;
        root /var/www/blog;
        index index.html;

        location / {
                try_files $uri $uri/ =404;
        }
}

Then you would need to create A records for both example.com and blog.example.com pointing to the IP address of the load balancer. The load balancer passes the host request straight through to the Droplets, allowing them to decide how to respond.

Digital Ocean load balancer is very basic. It can only do one domain SSL using Let’s Encrypt. Just trying to add MORE ssl certs for one load balance suing multiple domains is impossible. For $10 that a bit expensive.

Your only option is to make the load balancer yourself using Nginx and Certbot. The Certbot will use Let’s Encrypt to automatically renew the certs.

As for the web back end you will need to learn Nginx with multiple virtual hosts using port 80.

Digital Ocean has a very nice article on how to create your own Nginx with SSL cert using Let’s Encrypt here: https://www.digitalocean.com/community/tutorials/how-to-set-up-let-s-encrypt-with-nginx-server-blocks-on-ubuntu-16-04

In AWS one load balancer (ALB) cost $15 can handle up to 50 domains (hard limit) and each domain can have its own SSL certificate from Cert manager which auto renews cert using AWS cert authority instead of Let’s Encrypt which is not trusted in many high level companies such as Shopify (web hooks). So depends on your needs you have 3 options.

Thank you very much for your detailed response. very happy to be wrong in this case. I was quite sure it was "yes, 1 lb for each domain)… thanks again, i am now sure i want to go with DO load balancer.