0

I have an AWS Load Balancer that serves traffic to multiple EC2 instances serving multiple websites with different domain names.

I'm trying to find a simple solution where any domain owners can set their domain (for example mydomain.com) forward traffic to my load balancer which is going to serve their website.

There's a similar question here about not being able to alias the apex of a domain, and that makes sense. However, due to this limitation, scenarios like mine where I don't necessarily want to host the domain owner's entire record (via delegation) but only want to serve their root domain's web traffic becomes tricky.

While it is possible to set A records instead of alias to forward traffic directly to the IP addresses of the load balancer, AWS doesn't gurantee IP adresses will stay static and also if the load balancer is recreated, the IP addresses will change making it a less desirable solution.

Any ideas on how I could serve a root domain's websites through Load Balancer would be great.

Additionally, the domain owners' don't necessarily host their domains in Route53.

2 Answers2

1

It depends on the DNS provider if they can provide a workaround for this issue. For example, Cloudflare provides CNAME flattening, where Cloudflare internally resolves the apex CNAME entries to IP addresses.

There is no generic solution that would apply to all DNS providers.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
  • 1
    "There is no generic solution that would apply to all DNS providers." Not yet, but soon. The new SVCB/HTTPS records that are already used in the wild even if the specification is not yet a standard, completely allow to have the "CNAME at apex" feature, so in a standardized way. – Patrick Mevzek Feb 12 '22 at 09:09
  • True, but that requires support from applications, so it will take time before it is realistic for all the use cases. – Tero Kilkanen Feb 12 '22 at 11:01
  • Except that iOS (hence I guess Safari) is already consuming those records... As is Google Chrome, in an experiment that will convert to public use (https://bugs.chromium.org/p/chromium/issues/detail?id=1052476). See my longer answer at https://serverfault.com/a/1075524/396475 for more details (but already very much outdated as 6 months old) – Patrick Mevzek Feb 12 '22 at 15:46
  • 1
    My point is that even if support is available in recent browsers, you might still have visitors with older browsers where this does not help. – Tero Kilkanen Feb 12 '22 at 16:54
  • Amazing! CNAME flattening by Cloudflare looks like a promising solution. Hopefully more DNS providers will start introducing these features until the SVCB/HTTPS RRs become mainstream. – Arpan Adhikari Feb 12 '22 at 23:28
0

Answering my own question since it solved my problem and might be helpful for someone else in the future.

Turns out you can create AWS Load Balancer with pre-allocated IP addresses.

Here's the high level process:

  1. From EC2 console, allocate an Elastic IP Address.

allocate an EIP

  1. When you create a new network load balancer you will be able to select this IP as your LB's public IP for a Subnet. You can allocate multiple EIPs and assign them to each Subnet.

create a new NLB

This solved the problem for me because I no longer have to contact domain owners to keep updating their DNS records (I don't host their entire domain) and can also keep recreating the NLB and reassigning the same set of Public IPs to it.