【发布时间】:2019-07-17 19:11:37
【问题描述】:
Parse 服务器部署在应用程序负载均衡器后面的 AWS Elastic Beanstalk 上。
EB 环境 URL 为:example.us-east-1.elasticbeanstalk.com。外部 CNAME 记录 parse.example.com 指向该环境 URL。
解析服务器需要配置:
-
serverURL(内部用于服务器调用自身,例如云代码) -
publicServerURL(用于构成客户端公开调用的 URL)
对于publicServerURL,使用https://parse.example.com/parse 似乎很明显,因为公共客户端将调用此端点。
但serverURL 需要设置为私有 URL,否则服务器会通过 Internet 网关向自己发送请求,这将产生“数据传输成本”在 AWS 中。
当我 eb ssh 进入 EC2 实例时,parse.example.com 和 example.us-east-1.elasticbeanstalk.com 都解析为负载均衡器的 public IP。
nslookup parse.example.com
Server: 172.31.0.2
Address: 172.31.0.2#53
Non-authoritative answer:
parse.example.com canonical name = example.us-east-1.elasticbeanstalk.com.
Name: example.us-east-1.elasticbeanstalk.com
Address: 52.72.xxx.xxx
Name: example.us-east-1.elasticbeanstalk.com
Address: 52.45.xxx.xxx
nslookup example.us-east-1.elasticbeanstalk.com
Server: 172.31.0.2
Address: 172.31.0.2#53
Non-authoritative answer:
Name: example.us-east-1.elasticbeanstalk.com
Address: 52.72.xxx.xxx
Name: example.us-east-1.elasticbeanstalk.com
Address: 52.45.xxx.xxx
那么必须为serverURL 设置什么才能对私有 IP 进行内部调用?
【问题讨论】:
-
您可以在 EC2 管理控制台中查看负载均衡器吗?如果您从那里获取 DNS 名称,则当从 VPC 内部解析时,它应该解析为私有 IP 地址。
-
LB DNS 名称不能更改吗?例如,如果我在 EB 中交换两个环境的 URL。
-
@JohnRotenstein - 根据我的经验(我已经对此进行了很多研究),公共 ALB DNS 名称总是解析为公共 IP,而不是私有 IP(与 EC2 或 RDS 的 DNS 名称不同实例)。
-
或者,当服务器需要调用自身时,我可以使用 EC2 实例私有 IP。但是我只能在 node.js 中的解析服务器初始化期间设置一次。该 IP 在实例的生命周期内会发生变化吗?
-
或者我可以将EB添加到VPC并设置静态私有IP吗?
标签: amazon-web-services amazon-ec2 parse-server amazon-elastic-beanstalk