将多个子域映射到同一个 S3 存储桶 [英] Map multiple subdomains to same S3-bucket
问题描述
有什么方法可以将多个(数千个)子域映射到一个 s3 存储桶?如果是这样,是否也可以将其映射到每个子域的存储桶中的特定路径?
Is there some way to map multiple (thousands) of subdomains to one s3-bucket? If so is it also possible to map it to a specific path in the bucket for each subdomain?
我希望 test1.example.com 映射到 mybucket/test1 和 test2.example.com 映射到 mybucket/test2.
I want test1.example.com to map to mybucket/test1 and test2.example.com to map to mybucket/test2.
我知道使用普通的 dns 记录不可能完成最后一部分,但也许有一些漂亮的 Route 53 功能?
I know the last part isn't possible with normal dns-records but maybe there is some nifty Route 53 feature?
推荐答案
直接使用 S3 是不可能的.一个 S3 存储桶只能使用 1 个子域.
It's not possible with S3 directly. You can only use 1 subdomain with an S3 bucket.
但是,您可以将多个子域映射到一个Cloudfront 分布.
However you can map multiple subdomains to a Cloudfront distribution.
更新(感谢 @SimonHutchison 的评论 下面)
您现在最多可以将 100 个备用域映射到 Cloudfront分发 - 参见 http://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_cloudfront
You can now map up to 100 alternate domains to a Cloudfront distribution - see http://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_cloudfront
您还可以使用通配符将任何子域映射到您的发行版:
You can also use a wildcard to map any subdomain to your distribution:
在备用域名中使用 * 通配符
当您添加备用域名时,您可以在域名的开头而不是指定子域个别.例如,备用域名为*.example.com,您可以在对象 URL 中使用以 example.com 结尾的任何域名,例如 www.example.com,product-name.example.com 和 marketing.product-name.example.com.这无论域名如何,对象的名称都是相同的,因为例子:
When you add alternate domain names, you can use the * wildcard at the beginning of a domain name instead of specifying subdomains individually. For example, with an alternate domain name of *.example.com, you can use any domain name that ends with example.com in your object URLs, such as www.example.com, product-name.example.com, and marketing.product-name.example.com. The name of an object is the same regardless of the domain name, for example:
www.example.com/images/image.jpg
product-name.example.com/images/image.jpg
marketing.product-name.example.com/images/image.jpg
这篇关于将多个子域映射到同一个 S3 存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!