如何解析为AWS EB负载均衡器的私有IP?

时间:2019-02-24 02:57:13

标签: amazon-web-services amazon-ec2 parse-server amazon-elastic-beanstalk

Parse Server部署在Application Load Balancer后面的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网关向自身发送请求,这会产生“数据转移成本”

当我eb ssh进入EC2实例时,parse.example.comexample.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进行内部呼叫?

1 个答案:

答案 0 :(得分:0)

我最终将服务器设置为http://localhost/parse来调用它自己-这是显而易见的解决方案。