Amazon CloudFront 不遵守我的 S3 网站存储桶的 index.html 规则 [英] Amazon CloudFront Doesn't Respect My S3 Website Bucket's index.html Rules

查看:25
本文介绍了Amazon CloudFront 不遵守我的 S3 网站存储桶的 index.html 规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用静态网站托管选项在 Amazon S3 上托管一个静态网站,这样 S3 将呈现一个文件夹,而无需让我明确指向我的 index.html 文件.

I'm hosting a static website on Amazon S3 using the static website hosting option, so that S3 will render a folder without making me explicitly point to my index.html file.

例如,这是指向我的 S3 存储桶中某个页面的直接链接:http://new.rdegges.com.s3-website-us-east-1.amazonaws.com/category/2009/ 如您所见,当您访问URL,Amazon S3 会自动在该目录中呈现 index.html 文件,让我拥有干净的 URL.

For instance, here is a direct link to a page in my S3 bucket: http://new.rdegges.com.s3-website-us-east-1.amazonaws.com/category/2009/ As you can see, when you visit that URL, Amazon S3 automatically renders the index.html file inside of that directory, allowing me to have clean URLs.

这在 S3 上一切正常.我遇到的问题是让 Amazon Cloudfront 也正确处理这种行为.当我创建一个 Cloudfront Distribution 并将我的 S3 存储桶指定为源并告诉它使用index.html"作为根时,S3 的 index.html 行为刚刚停止一起工作.

This all works fine on S3. The problem I'm having is getting Amazon Cloudfront to properly handle this behavior as well. When I create a Cloudfront Distribution with my S3 bucket specified as the origin, and tell it to use 'index.html' as a root, the index.html behavior that S3 has just stops working all together.

例如,这里是我在 Cloudfront 上与上面相同的 URL:http://d1mj00c6pby3gc.cloudfront.净/类别/2009/

For instance, here is my same URL as above on Cloudfront: http://d1mj00c6pby3gc.cloudfront.net/category/2009/

不幸的是,上面的 URL 不起作用,但如果我手动指定索引文件,它会起作用,例如:http://d1mj00c6pby3gc.cloudfront.net/category/2009/index.html

Unfortunately, the URL above does NOT work, but if I manually specify the index file, it does, e.g: http://d1mj00c6pby3gc.cloudfront.net/category/2009/index.html

我的问题是:我需要如何配置 Cloudfront 以使其尊重我网站的 S3 存储桶设置?

My question is: how do I need to configure Cloudfront such that it respects my S3 bucket settings for my website?

推荐答案

S3 网站功能可与 Amazon CloudFront 结合使用.但是,S3 网站使用的域名与常规 S3 存储桶不同.在这种情况下,您需要将 CloudFront 分配的源配置的 Origin Domain Name 设置为 new.rdegges.com.s3-website-us-east-1.amazonaws.com.

S3 Website features can be used in conjunction with Amazon CloudFront. However, S3 Website uses a different domain name than regular S3 buckets. In this case, you'll need to set the Origin Domain Name of your CloudFront distribution's origin configuration to new.rdegges.com.s3-website-us-east-1.amazonaws.com.

您可以从 S3 上的静态网站托管面板获取此 URL(端点):

You can take this URL (Endpoint) from the Static Website Hosting panel on S3:

一旦 CloudFront 指向 S3 网站域名,S3 网站功能就应该可以使用了.

Once CloudFront is pointed to the S3 website domain name, the S3 web site features should work.

这篇关于Amazon CloudFront 不遵守我的 S3 网站存储桶的 index.html 规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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