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.

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
March 1, 2018
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.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.