Sharing your load balancer with other sites

I have multiple domains under my account and would like to use a single load balancer for all these different domains. The documentation says: “You can share your load balancer with other sites in your account by creating a canonical name (CNAME) record. This is useful for sharing configurations with multiple other domains so you do not have to create new load balancers for each site.” Is there an example that shows how to configure the DNS records to use a single load balancer to serve multiple domains?

  1. Create an origin server which serves and
  2. Create a second origin server which serves the same 2 websites.
  3. Create a load balancer called and specify the origins from steps 1 & 2.
  4. Create a www cname in the and zones which points to`.

Thanks for suggestion. With that approch, it seems to me I must have an A record for example,com that points to an IP address, but a www CNAME that points to lb,example,com. In such case, what would happen if someone tried to access example,com using example,com, instead of www,example,com?
What I did was to remove the A record and simply use CNAME to point to lb,example,com. That way, both example,com and www,example,com point to load balancer. Do you see any problem with my approach? (Looks like I cannot put any URL in my reply. I replaced . with ,)

Thanks again for your help.

/Technically/ you can’t have a CNAME record for the APEX but Cloudflare supports CNAME flattening at the APEX. So as long as you’re using Cloudflare for hosting your DNS in Full which 99.9% of customers are then using a CNAME for pointing to will work the same way (and obviously you’d configure your origins in that example to accept traffic for the root hostnames as well).

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.