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

查看:283
本文介绍了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也能正确处理此行为。当我创建一个以我的S3存储桶为起点的Cloudfront发行版,并告诉它使用'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.net/category/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发行版本的原始配置的原始域名设置为 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天全站免登陆