amazon ec2 如何使用负载均衡器将域名路由到实例?

How does amazon ec2 work in regards to routing a domain name to an instance using load balancers?

amazon ec2 如何使用负载均衡器将域名路由到实例?

请求从域名到ec2实例的流程是怎样的?

交通流向如下图

Hosted zone => Load balancer => Target group => EC2 Instance.

  1. 因此,当您向域名发出请求时,请求将按照 hosted zone.
  2. 中的“规则”进行路由

A hosted zone is a container for records, and records contain information about how you want to route traffic for a specific domain, such as example.com, and its subdomains (acme.example.com, zenith.example.com). A hosted zone and the corresponding domain have the same name.

  1. 在您在托管区域中设置的规则之一中,应该有一条规则(一条记录)将流量从您的域名定向到负载均衡器。记录为“A type”。负载均衡器随后将流量路由到目标组。

A load balancer distributes incoming application traffic across multiple EC2 instances in multiple Availability Zones. ... Elastic Load Balancing detects unhealthy instances and routes traffic only to healthy instances. Your load balancer serves as a single point of contact for clients.

  1. 目标组然后有称为目标的记录。这针对 EC2 instance idporthealth status 等存储信息。目标信息告知流量是如何路由的。如果 health status 不健康,流量将路由到具有健康状态的目标,或者返回错误作为响应。

A target group tells a load balancer where to direct traffic to : EC2 instances, fixed IP addresses; or AWS Lambda functions, amongst others. When creating a load balancer, you create one or more listeners and configure listener rules to direct the traffic to one target group.

  1. 当流量从目标组路由到健康目标时,它会转到 EC2 instance id 所属的 EC2 实例。在 EC2 实例中,应该有一个服务器 运行 接受请求并返回适当的响应。

An Amazon EC2 instance is a virtual server in Amazon's Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure.

AWS 上有这方面的文档,您可以查看包含详细信息的页面 Routing traffic to an ELB load balancer - Amazon Route 53

此外,在上述文档中还有指向其他页面的链接,例如如何使用 Route 53 等,您将全面了解您正在寻找的内容。