在具有自定义域的S3网站上设置索引文档 [英] Setting index document on S3 website with custom domain

查看:106
本文介绍了在具有自定义域的S3网站上设置索引文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为S3托管的网站设置索引文档.我

I'm trying to set an index document for my S3 hosted website. I've

  1. 启用存储桶中的网站托管
  2. 将索引文档设置为"index.html"
  3. 上传了index.html文件
  4. 将index.html文件设为公开.

使用原始AWS URL导航到存储桶的根目录时,索引文档有效,但使用自定义域时,索引文档无效:

The index document works when navigating to the root of the bucket using the raw AWS url, but does not work when using a custom domain:

http://static.appgrinders .com.s3-website-us-east-1.amazonaws.com/index.html (有效)
http://static.appgrinders.com.s3-website- us-east-1.amazonaws.com (有效)
http://static.appgrinders.com/index.html (有效)
http://static.appgrinders.com (访问被拒绝-403错误)

http://static.appgrinders.com.s3-website-us-east-1.amazonaws.com/index.html (works)
http://static.appgrinders.com.s3-website-us-east-1.amazonaws.com (works)
http://static.appgrinders.com/index.html (works)
http://static.appgrinders.com (Access denied - 403 error)

推荐答案

您的DNS配置不正确.

Your DNS isn't configured correctly.

您要指向不支持索引文档的REST端点之一(CNAME s3.amazonaws.com).您需要DNS指向网站托管终结点,在本例中为CNAME static.appgrinders.com.s3-website.us-east-1.amazonaws.com.该端点在S3控制台中可见.

You are pointing to one of the REST endpoints (CNAME s3.amazonaws.com), which doesn't support index documents. You need the DNS to point to the web site hosting endpoint, in this case it's CNAME static.appgrinders.com.s3-website.us-east-1.amazonaws.com. This endpoint is visible in the S3 console.

此更改将解决您的问题.

This change will fix your issue.

http://docs.aws.amazon.com/AmazonS3/Latest/dev/WebsiteEndpoints.html

错误配置的本质(在我在DNS中确认之前)是XML错误.承载端点的网站不会返回XML错误-它们返回相同的信息,但是将它们包装在一些简单的HTML中,而不是XML.

The giveaway of the nature of the misconfiguration (before I confirmed in DNS) was the XML error. The web site hosting endpoints don't return XML errors -- they return the same information, but it's wrapped in some simple HTML, instead of XML.

但是,请注意,如果您希望通过SSL访问您的站点,则仍然需要使用CloudFront. S3中的自定义域需要CloudFront的帮助来支持SSL.与REST终结点不同,托管终结点的网站根本不侦听端口443.

Note, however, that you will still need to use CloudFront if you want your site to be accessible with SSL. Custom domains in S3 require CloudFront's help for SSL support. The web site hosting endpoints, unlike the REST endpoints, don't listen on port 443 at all.

在CloudFront配置中,您需要避免相同的错误-不要从下拉列表中选择存储桶名称,因为这会将请求发送到REST端点.您需要提供网站端点主机名作为源.

In the CloudFront configuration, you'll need to avoid the same error -- don't select the bucket name from the dropdown list, since this will send requests to the REST endpoint. You'll need to supply the web site endpoint hostname as the origin.

这篇关于在具有自定义域的S3网站上设置索引文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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