AWS Route 53 与 Cloudfront 的集成错误 (403)

AWS Route 53 integration with Cloudfront error (403)

我最近在遵循 this tutorial 后向 AWS 部署了一个 React 应用程序,一切正常,除了当我想集成我最近使用 AWS Route 53 购买的自定义域时,出现错误 (403) .

对于 Route 53 与 CloudFront 的集成,我按原样按照 docs 中的这些步骤操作,我知道我的问题与某种权限有关,但我不知道具体在哪里我做错了。

看起来您正在尝试使用 http 而不是 https。

如果您启用了http,则表示无法到达目标方法或路径。

已解决,我的问题与 CloudFront[=17 的未分配 备用域名 (CNAME) 有关=]分布.

添加有关上述两个答案的附加信息。

如何解决来自 Amazon CloudFront 的错误 "The request could not be satisfied. Bad Request" 中所述 :

This error message "The request could not be satisfied. Bad Request." is from the client and the error can occur due to one of the following reasons:

1) The request is initiated over HTTP, but the CloudFront distribution is configured to allow only HTTPS requests.

2) The requested alternate domain name (CNAME) isn't associated with the CloudFront distribution.

#1的解决方案:
打开 Amazon CloudFront 控制台 -> Select 相关分配 -> Go Behaviors 视图 -> 选择与请求匹配的行为并编辑 -> 然后select在Viewer Protocol Policy之间的选项为:HTTP and HTTPSRedirect HTTP to HTTPS.

#2的解决方案:
由于 this release 当您将备用域名添加到分配时,您还必须将 SSL/TLS 证书附加到覆盖备用域名的该分配。

因此,首先请确保在更新分发以添加备用域名之前执行以下操作:

A) 向域名提供商(GoDadday、CloudFlare、Route 53 等)注册域名。

B) 将来自授权证书颁发机构(例如 - Let's Encrypt)的证书添加到 CloudFront,涵盖您计划用于分发的域名,以验证您是否有权使用该域. (阅读 here 中的更多内容)。

然后才:
打开 Amazon CloudFront 控制台 -> 一般视图 -> 编辑 -> 备用域名 (CNAME) -> 输入您要与 CloudFront 分配关联的 CNAME(例如 wwwhome)。