“将所有请求重定向到另一个主机名”正是您想要的。
但是,必须正确配置 DNS 才能将请求实际发送到 S3 存储桶。在您的情况下,这就是问题所在——您实际上并没有向 S3 发送对该主机名的请求。你将它们发送到其他地方。以下响应显然不是来自 S3:
$ curl -v dleybz.com/random/path/here.html
* About to connect() to dleybz.com port 80 (#0)
* Trying 216.239.32.21... connected
> GET /random/path/here.html HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: dleybz.com
> Accept: */*
>
< HTTP/1.1 302 Found
< Location: http://www.dleybz.com
< Date: Wed, 02 Dec 2015 21:56:39 GMT
< Content-Type: text/html; charset=UTF-8
< Server: ghs
< Content-Length: 218
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.dleybz.com">here</A>.
</BODY></HTML>
* Connection #0 to host dleybz.com left intact
* Closing connection #0
这看起来更像是您正在使用(我推测,基于响应)Google Domains Redirection 进行某种域重定向。
您的 DNS 当前未由 Route 53 托管。这本质上是在域的顶点使用存储桶的要求(技术而非政策),因为在区域顶点不允许使用 CNAME 记录。 Route 53 具有称为 Alias 记录的内置集成功能,允许在没有 CNAME 记录的情况下进行此映射 - 您需要配置这些并将您的 DNS 提供程序切换到 Route 53,与您已阅读的教程的第 3 节和第 4 节一致链接到问题中。
还请注意,使用一点命令行技巧来强制将请求发送到 S3 而不是当前发送到的任何地方,您可以证明存储桶正在按应有的方式工作——它只是请求没有到达。
我们将向 us-east-1 中的 S3 网站端点发送请求并重写 Host: 标头:
$ curl -v -H 'Host: dleybz.com' http://s3-website-us-east-1.amazonaws.com/random/path/here.html
* About to connect() to s3-website-us-east-1.amazonaws.com port 80 (#0)
* Trying 54.231.9.252... connected
> GET /random/path/here.html HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Accept: */*
> Host: dleybz.com
>
< HTTP/1.1 301 Moved Permanently
< x-amz-id-2: bS9KJJ28qo+AVoxGWwLdavXilX+HFe4suNFdlJsFVfoJl/gFTb/eIToafnjpKLLw4syaYG9jaF0=
< x-amz-request-id: 0090A3CCCCC7AD2A
< Date: Wed, 02 Dec 2015 22:14:12 GMT
< Location: http://www.dleybz.com/random/path/here.html
< Content-Length: 0
< Server: AmazonS3
<
* Connection #0 to host s3-website-us-east-1.amazonaws.com left intact
* Closing connection #0
请注意,当请求实际转到 S3 时,重定向会在保留路径的情况下按预期工作。