I am having Network Load Balancer attached to an target group having 2 EC2 instances in different availability zones. I want load balance on both of them.
I want an EIP in front of NLB i.e. when I hit the EIP address it should send its traffic to the NLB dns endpoint.
OR
Can I place an EC2 in front of NLB having an elastic IP which resolves in NLB dns name.
What are different approaches I can try and what are all its pros and cons.
2
Answers
If you wish to load balance requests coming in from the internet, then i suggest that you should create an internet facing network load balancer spread across at least 2 availability zones (AZ). That gives high availability in case of some failure of a single AZ.
I think you should not place an EC2 or anything else in front of the NLB (network load balancer), because that will defeat the purpose of the NLB. The NLB nodes need to be in a public subnet and receiving the requests directly.
The two (or more) EC2 instances (the load balancer nodes across which traffic will be balanced) should be configured with a public IP each and spread across the NLB availability zones. Those ips can be user chosen elastic ips (EIPs), if not NLBcan allocate public ips automatically. A target group consisting of those instances should created and the target group should be associated with the NLB.
Finally, once the NLB is created, AWS will assign a dns name like NLB-xxxxxx-amazonaws.com which will be the public endpoint that the requests coming in should target. Hope that helps.
Yes, you can attach elastic IPs to internet facing network load balancers. There’s a full walkthrough on how to do that here: https://repost.aws/knowledge-center/elb-attach-elastic-ip-to-public-nlb