Score:0

How could I use single elastic IP for multiple instances (AWS)?

et flag

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?

Score:0
gp flag
Tim

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.

LuckyLuke avatar
et flag
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?
cn flag
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).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.