大网数据广告活动
服务器运维问答

How can I use a static IP address with an Application Load Balancer in a highly available manner?

· 52CE 我爱测

I'm overseeing an integration for a customer and their vendor needs a number of IP Addresses to whitelist. The originating server(s) is an Elastic Beanstalk Instance fronted by an Application Load Balancer with all the trimmings …

问题原文

原帖链接 · sean · CC BY-SA 4.0

I'm overseeing an integration for a customer and their vendor needs a number of IP Addresses to whitelist. The originating server(s) is an Elastic Beanstalk Instance fronted by an Application Load Balancer with all the trimmings via Route53.

That's not going to work, since you can't assign a static IP to Application Load Balancers by definition (and I do need the Layer 7 features).

I can't just proxy the specific requests to the vendor via code and an additional EC2 instance because it's a two-way integration.

I've read through this article, but that frankly seems like a hack and not something I'd do in a production environment.

It certainly seems like I need some combination of an NLB with an ALB, but again, the references article introduces a ton of moving parts.

Edit:

  • I am using a VPC
  • The instance itself lives in a private subnet
  • The ALB lives in a public subnet and both have the necessary routing to communicate
  • I'm almost certain I'm talking in circles trying to convince myself Static IP !== Single Point of Failure

已采纳解答

原帖链接 · Michael - sqlbot · CC BY-SA 4.0

There is currently only one way to associate static IP addresses with Application Load Balancer (ALB) -- AWS Global Accelerator.

Static Anycast IPs – Global Accelerator uses Static IP addresses that serve as a fixed entry point to your applications hosted in any number of AWS Regions. These IP addresses are Anycast from AWS edge locations, meaning that these IP addresses are announced from multiple AWS edge locations, enabling traffic to ingress onto the AWS global network as close to your users as possible. You can associate these addresses to regional AWS resources or endpoints, such as Network Load Balancers, Application Load Balancers, and Elastic IP addresses. You don’t need to make any client-facing changes or update DNS records as you modify or replace endpoints.

https://aws.amazon.com/blogs/aws/new-aws-global-accelerator-for-availability-and-performance/

Global Accelerator allocates two static IPs from two Network Zones¹, and these are unique to your deployment -- not shared. These are advertised out to the Internet via peering connections at multiple locations on the AWS Edge Network (the same network where CloudFront, Route 53, and S3 Transfer Acceleration all operate -- it has more points of presence than just the AWS regions, and AWS-managed fiber connections to the regions). Then you associate the endpoints -- ALB, NLB, EIP, or EC2 Instance (without EIP) -- with the Global Accelerator instance, and traffic from the edge location where the requests arrive is NAT-ed to your balancer.

When Global Accelerator was initially launched, it relied on Source NAT to tie the global addresses to the VPC devices, so you couldn't use the client source IP or the X-Forwarded-For header from the ALB to determine the client IP address in real-time; however, that has changed -- X-Forwarded-For now correctly identifies the client IP address when an ALB is used with Global Accelerator in most AWS regions.

Client IP address preservation only works when the endpoint is an ALB or an EC2 instance (without EIP). It doesn't work with EIP endpoints or Network Load Balancers; for those cases you can only cross-correlate them later using flow logs, which capture source/destination tuples as well as the intermediate NAT address that your application will see.


Importantly, ALB is inbound only (connections are only ever established from outside to inside, regardless of the ultimate direction of data transfer), so if your servers are also initiating connections, you need a separate solution for a static source address -- a NAT Gateway.

One NAT Gateway per availability zone, placed on a public subnet, can serve as the default gateway for one or more private subnets within the availability zone, so that all instances on those subnets use the same source IP when contacting the Internet. NAT Gateway is not a black box in a physical place -- it's a feature of the network infrastructure, so it's intrinsically fail-safe and not considered a single point of failure within a single AZ. You can share a single NAT Gateway across availability zones, but then you do have a single point of failure if something catastrophic occurs in that one availability zone (and you'll pay slightly more to transport Internet traffic across AZ boundaries, compared to placing one NAT Gateway in each AZ). The NAT Gateway requires no application changes, because it isn't a proxy -- it's a network address translator that's transparent to the instances that are located on the subnets that are configured to use it. Each NAT Gateway has a static EIP.


¹ network zone is new AWS terminology, introduced with Global Accelerator. It describes the fact that the two IP addresses are, internally, handled by different infrastructure.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-01-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。