如何使用路由 53、cloudfront 分发和 Elastic beanstalk 修复 504 错误

Jam*_*mes 5 amazon-cloudfront amazon-route53 amazon-elastic-beanstalk

我无法使用 Elastic beanstalk、cloudfront 分发和路由 53 让我的 nodejs api 工作。我需要我的 api 在 SSL 后面运行,这就是我使用 cloudfront 分发的原因。我有以下设置。

当我访问我的 api 时,https://api.mydomain.com我收到 504 错误消息,并显示以下错误消息。

我的 api 运行的实际 url(成功地,使用 Nodejs Elastic 和 beanstalk)是http://dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com。我只想将该 urlapi.mydomain.com与 SSL 一起屏蔽。

我有什么地方做错了吗/你能建议我尝试一下吗?

浏览一下cloudfront的配置,这看起来很奇怪,图片显示了以S3为前缀的设置,但这个api不在S3上(至少不是直接在S3上),而是由elastic beanstalk托管。

在值中提到 S3 的 cloudfront 设置,它位于 beanstalk 中(不是 S3)

谢谢,

错误信息

504 ERROR
The request could not be satisfied.
CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection. 
If you received this error while trying to use an app or access a website, please contact the provider or website owner for assistance. 
Run Code Online (Sandbox Code Playgroud)

53号公路

  • 名称 = api.mydomain.com
  • 类型 = (A) 别名目标 = wqsdn31817

CloudFront 发行版

  • 域名=wqsdn31817

  • origin = dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com (如果我访问此网址,我会看到我的 api 正在运行)

  • SSL 证书 = api.mydomain.com

  • 状态 = 已部署

  • 源设置/源域名 = http://dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com

  • 源设置/源协议策略 = 仅 HTTPS

弹性豆茎

  • Nodejs api(使用express)

  • 在 beanstalk 环境 ID:e-1nasn4,URL:dummy-env.n1eijsdai.eu-west-1.elasticbeanstalk.com

Jam*_*ean 3

仅当 CloudFront 无法建立 TCP 连接或 HTTP 第一个字节响应花费的时间超过 Origin 读取/响应超时中配置的时间时,CloudFront 才会提供 504。

您的应用程序是否直接与 beanstalk 链接一起工作,或者您是否有任何基于 IP 的安全组限制?