0

What would be best way to achieve such thing:

I have limited amount of elastic ips, and I have bunch on EC2 instances to launch small apps.

I have an idea to have load-balancer or an EC2 instance that could route traffic to any other EC2 instances.

For example there would be 3 instances:

  • Instance 1 (ec2-00-00-0-01.eu-west-2.compute.amazonaws.com)
  • Instance 2 (ec2-00-00-0-02.eu-west-2.compute.amazonaws.com)
  • Instance 3 (ec2-00-00-0-03.eu-west-2.compute.amazonaws.com)

I would want to use Public IPv4 DNS of these instances.

So for example how could I have single place that could route traffic based on domain name.

EC2 instance (nginx reverse proxy) or A load-balancer in AWS would listen for requests of domains:

  • instance1.com (would route traffic to ec2-00-00-0-01)
  • instance2.com (would route traffic to ec2-00-00-0-02)
  • instance3.com (would route traffic to ec2-00-00-0-03)

What would be your approach to handle such scenario?

LuckyLuke
  • 103
  • 2

1 Answers1

0

Do your applications need to be address by IP? Are they standard http(s)? If appropriate just set up an ALB, use the domain names provided, and don't bother with static IPs.

Two things I'm not sure you know:

  • Within a VPC only private IPs are used. NAT to public IPs is done at the internet gateway. i.e. the load balancer connects to the instances using their private IP, which never changes

  • When you use a load balancer you put the CNAME into DNS, rather than the IP address. Basically IP addresses become irrelevant if you use a load balancer.

Tim
  • 31,888
  • 7
  • 52
  • 78
  • They are standard HTTP / HTTPS web apps. The one issue I have is that in case of reboot - IP of the EC2 will change? And then I will need to update IP for the domain name it points to? – LuckyLuke Nov 09 '22 at 09:08
  • 1
    When behind a load balancer, the IP address of the EC2 instance(s) is irrelevant. This is because the domain points to the load balancer, not to your instance(s). – Matt Houser Nov 09 '22 at 14:55