在一个CloudFront分发中托管多个S3来源 [英] Hosting multiple S3 origins under one CloudFront distribution

查看:185
本文介绍了在一个CloudFront分发中托管多个S3来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在同一CloudFront发行版中托管多个S3源?假设我有存储桶A和存储桶B都托管静态网站-是否可以将它们都添加为发布的来源,并指定路径(例如 / alternate 作为存储桶B的来源,以便访问 http://< distribution> / 将您带到由存储桶A托管的网站并访问 http://< distribution> / alternate 将您带到存储桶B托管的网站?从到目前为止的内容来看,似乎有多个起源,而不一定有多个S3起源。

Is it possible to host multiple S3 origins under the same CloudFront distribution? Let's say I have bucket A and bucket B which both host static websites--could I add them both as origins to a distribution, and specify a path e.g. /alternate for the origin from bucket B so that visiting http://<distribution>/ took you to the website hosted by bucket A and visiting http://<distribution>/alternate brought you to the one hosted by bucket B? From what I've read so far it seems possible to have multiple origins, not necessarily multiple S3 origins.

推荐答案

您可以将多个S3起源添加到CloudFront分布中

You can add multiple S3 origins to a CloudFront distribution

但是,行为被锁定到特定的来源。行为控制路径。因此,如果Origin A / S3 A使用/ static,则无法使/ static转到/ Origin B / S3 B

However, behaviors are locked to a specific origin. Behavior controls the path. So, if /static is used by Origin A/S3 A, you can't have /static go to /Origin B/S3 B

有人建议将多个CloudFront与相同的CNAME。那也不行。 CloudFront将不允许在多个发行版中使用相同的CNAME。

Someone suggested using multiple CloudFronts with the same CNAME. That does not work either. CloudFront will not allow the same CNAME to be used in multiple distributions.

从学术上来讲,这可以通过LambdaEdge或检查S3 A的某些其他外部过程来实现,并且如果它不可用(例如-在推送新代码时正在维护中),它可以将/ static的CF行为更新为Origin B / S3 B。

Academically speaking, this may be possible through LambdaEdge or some other external process that is checking S3 A, and if it is unavailable (say - under maintenance while new code being pushed), it can go and update CF Behavior for /static to Origin B/S3 B.

我希望AWS针对此用例提出了一种更为优雅的解决方案。就像允许在多个发行版中使用相同的CNAME一样,或者与S3存储桶提供某种R53集成(永远不要尝试将两个不同的S3存储桶放在R53之后..可能不会起作用,因为主机头会发生变化)

I wish AWS came up with a more elegant solution to this use case. Like allowing same CNAME in multiple distributions, or providing some kind of R53 integration with S3 buckets (never tried putting two different S3 buckets behind R53 .. probably will not work because the host header would change)

这篇关于在一个CloudFront分发中托管多个S3来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆