问题描述
Amazon.com 刚刚宣布可以在 S3 存储桶中托管静态网站.我去了他们的设置页面 http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?WebsiteHosting.html 并为我的静态网站创建了一个存储桶,它运行良好.我有一个 http://[my 存储桶名称].s3-website-us-east-1.amazonaws 形式的 URL.com/.
Amazon.com just announced that one can host static web sites in a S3 bucket. I went to their setup page at http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?WebsiteHosting.html and created a bucket for my static web site, and it worked fine. I have an URL of the form http://[my bucket name].s3-website-us-east-1.amazonaws.com/.
但是,我想将我拥有的子域(例如 static.mydomain.com)指向我在 Amazon S3 上的静态网站.有人知道怎么做吗?
However, I would like to point a subdomain that I own (e.g. static.mydomain.com) to my static web site at Amazon S3. Has anybody figured out how to do that?
感谢您能给我的任何帮助.
I appreciate any help you can give me.
推荐答案
事实证明,要使其工作,您不能仅仅将任意子域映射到任意存储桶.完全限定的子域名必须与 S3 存储桶名称相同.
It turns out that to make it work, you cannot just map any arbitrary subdomain to any arbitrary bucket. The fully qualified subdomain name must be the same as the S3 bucket name.
- 假设您的网站名称是 static.mydomain.com.然后您需要创建一个同名的 S3 存储桶,名为 static.mydomain.com.
- 一旦您将该存储桶配置为 S3 静态网站,就会为其分配一个 URL,类似于 http://static.mydomain.com.s3-website-us-east-1.amazonaws.com强>.
- 转到您的域名托管服务商并将您的子域映射到步骤 2 中的 URL.在 enom.com 中,这意味着将主机static"映射到地址"static.mydomain.com.s3-website-us-east-1.amazonaws.com"作为 CNAME 记录.
- Suppose the name of your site is static.mydomain.com. Then you need to create a S3 bucket with that same name, named static.mydomain.com.
- Once you configure that bucket as a S3 static web site, it will have a URL assigned to it that looks something like http://static.mydomain.com.s3-website-us-east-1.amazonaws.com.
- Go to your domain host and map your subdomain to the URL from step 2. In enom.com, that meant mapping the host "static" to the address "static.mydomain.com.s3-website-us-east-1.amazonaws.com" as a CNAME record.
感谢 Uriah 和 大卫 的建议.我最终在 亚马逊 AWS 论坛上得到了答案.
Thanks to Uriah and David for suggestions. I eventually got my answer at an Amazon AWS forum.
这篇关于Amazon S3:静态网站:自定义域或子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!