【问题标题】:How to fix 504 ERROR with route 53, cloudfront distribution and elastic beanstalk如何使用路由 53、云端分发和弹性 beantalk 修复 504 错误
【发布时间】:2019-11-11 06:32:46
【问题描述】:

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

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

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

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

查看 cloudfront 的配置,这看起来很奇怪,图片显示了以 S3 为前缀的设置,但此 api 不在 S3 上(至少直接),它由弹性 beanstalk 托管。

谢谢,

错误信息

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. 

53 号公路

  • name = 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

【问题讨论】:

  • 我遇到了类似的问题,但在 Lightsail 中使用 WordPress。一些请求成功,而另一些则失败(错误 504)。基本上,我使用 cloudfront 从 s3 为主要网站提供服务,而 /blog* 从 lightsail 实例提供服务。一开始还可以,但突然出现了问题。

标签: amazon-cloudfront amazon-elastic-beanstalk amazon-route53


【解决方案1】:

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

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

【讨论】:

  • 当我浏览 beanstalk 部署后提供的 url 时,我的 nodejs api 正在 http 上运行
  • Origin Settings/Origin Protocol Policy = HTTPS Only,你设置了这个云端,beantalk 是否也可以从浏览器/公共直接在 https 上工作?
猜你喜欢
  • 2016-02-08
  • 2020-04-02
  • 2019-07-05
  • 1970-01-01
  • 2017-11-25
  • 2013-04-28
  • 1970-01-01
  • 2019-08-07
  • 2023-03-15
相关资源
最近更新 更多