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

查看:33
本文介绍了使用自定义域在 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 错误)

推荐答案

您的 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天全站免登陆