将CloudFront与Elastic Beanstalk应用程序连接

发布于 2025-01-17 16:43:37 字数 1323 浏览 4 评论 0原文

我正在尝试将CloudFront与EBS连接。

设置是什么?

  • ebs托管nodejs应用程序。

  • CloudFront Origin设置为弹性负载平衡器并接受HTTPS 仅[CloudFront Config]

  • 正确添加了所有替代域。

  • ACM证书已添加到CloudFront [US EAST -N.VIRGINA]

  • EC2实例 / EB位于亚太地区。 ACM证书 安装在负载平衡器中也来自亚太地区。

我也在借助Load Balancer听众的帮助下重定向HTTP流量。

安全组允许流量到端口443。 没有AWS WAF设置。

原点设置: -

“在此处输入图像描述”

现在已经一天了。

我正在不断尝试。

我可以设置DNS A& AAA使用路由53记录到CloudFront,也获得下拉值。

我能够直接将域名停放到EBS&他们在HTTPS上正常工作。

获得502错误:无法满足请求。

已经尝试了 https:// /premumsupport/knowledge-center/resolve-cloudfront-bad-request-error/

我怀疑我的ELB是否有来自 Asia Pacific 的ACM证书,但是CloudFront中使用的ACM证书来自 美国东部,这是造成问题的吗?我现在无法更改EBS区域。

I am trying to connect cloudfront with EBS.

Whats the setup?

  • EBS is hosting a nodeJs application.

  • Cloudfront origin set to Elastic load balancer and accepts HTTPS
    only [Cloudfront config]

  • All Alternative domains are added correctly.

  • ACM certificate is added to Cloudfront [region US EAST - N.Virgina]

  • EC2 instance / EBS is in the region Asia Pacific. ACM certificates
    installed in load balancer are from Asia pacific too.

I am also redirecting http traffic with the help of load balancer listeners.

enter image description here

Security group allows traffic to port 443 .
No AWS WAF set.

Origin settings:-

enter image description here

It's been a day now.

I am trying continuously.

I am able to set DNS A & AAA record to the cloudfront using route 53, getting the dropdown value as well.

I am able to park domains directly to EBS & they work over https properly.

Getting 502 ERROR : The request could not be satisfied.

Already tried https://aws.amazon.com/premiumsupport/knowledge-center/resolve-cloudfront-bad-request-error/

I doubt my ELB has ACM certificate from Asia Pacific but the ACM certificate used in cloudfront is from US EAST , is that causing the issue? I can't change the EBS region now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

探春 2025-01-24 16:43:37

It seems that you did not setup https on your EB. But you are using HTTPS only origin. That's why it does not work. You have to have origin in http, or actually properly setup https on your EB.

痴意少年 2025-01-24 16:43:37

感谢@Marcin 发现了我愚蠢的错误!

这是因为ELB不接受

仅限 https

配置。
但我设置了侦听器将所有 HTTP 流量重定向到 HTTPS,
HTTPS 流量指向我的实例。

找出@Marcin提到的原因后

我如何解决问题:

  • 将cloudfront原始请求更改为仅http。

  • 设置自定义标头:

在此处输入图像描述

  • 然后向 ELB 添加一个新的侦听器,如果标头匹配,该侦听器会转发到我的实例,这将有助于 EBS 区分来自 Cloudfront 和其他来源的请求。

输入图片这里的描述

我仍然得到相同的响应,发现响应来自缓存。只需要使cloudfront 的缓存失效即可。完成了!

Thanks to @Marcin for finding out my stupid mistake!

It was because of the ELB not accepting

https only

config from cloudfront.
But i had set listeners to redirect all HTTP traffic to HTTPS,
and HTTPS traffic points to my instance.

After finding out the reason mentioned by @Marcin

How i solved the problem:

  • Changed cloudfront origin request to http only.

  • Set a custom header :

enter image description here

  • then added a new listener to ELB which forwards to my instance if the header match, it would help EBS differentiate requests from Cloudfront and other origins.

enter image description here

Still i was getting same response, found out the response was from cache. Just had to invalidate cache of cloudfront. And its done! ????

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文