简体   繁体   English

获取Bucketname时的S3 Static Website Hosting?

[英]S3 Static Website Hosting when Bucketname is taken?

I'm trying to host a simple static website from my AWS account with S3. 我正在尝试使用S3在我的AWS账户中托管一个简单的静态网站。 I had an old dusty account with lots of strange settings from testing over the years, I also had an S3 account with a 'mypersonaldomain.com' and 'wwww.mypersonaldomain.com' bucket. 我有一个旧的尘土飞扬的帐户,多年来测试中有许多奇怪的设置,我还有一个带有'mypersonaldomain.com'和'wwww.mypersonaldomain.com'桶的S3帐户。 Anyways I wanted to start fresh so I canceled the account to start new. 无论如何我想重新开始,所以我取消了帐户以开始新的。

Now when I go to create a 'mypersonaldomain.com' and 'www.mypersonaldomain.com' it says the bucket name is taken even though the account was deleted a while ago. 现在,当我创建'mypersonaldomain.com'和'www.mypersonaldomain.com'时,它表示即使帐户已被删除,也会获取存储桶名称。 I had assumed that amazon would release the bucketname back to the public. 我曾假设亚马逊会将桶名发回给公众。 However when I deleted the account, I didn't explicitly delete the buckets beforehand. 但是,当我删除帐户时,我没有事先明确删除存储桶。

I'm under the impression to use S3 for static website hosting the bucket names need to match the domain name for the DNS to work. 我的印象是使用S3进行静态网站托管,桶名称需要与DNS的域名相匹配才能工作。 However If I can't create a bucket with the proper name is there anyway I can use S3 for static hosting? 但是,如果我无法创建一个具有正确名称的存储桶,那么我可以使用S3进行静态托管吗? Its just a simple low traffic website that doesn't need to be in an EC2 instance. 它只是一个简单的低流量网站,不需要在EC2实例中。

FYI I'm using Route 53 for my DNS. 仅供我使用Route 53作为我的DNS。

[note 'mypersonldomain.com' is not the actual domain name] [注意'mypersonldomain.com'不是实际的域名]

One way to solve your problem would be to store your website on S3 but serve it through CloudFront: 解决问题的一种方法是将您的网站存储在S3上,但通过CloudFront提供:

  1. You create a bucket on S3 with whatever name you like (no need to match the bucket's name to your domain name). 您可以在S3上使用您喜欢的任何名称创建存储桶 (无需将存储桶的名称与您的域名相匹配)。
  2. You create a distribution on CloudFront . 在CloudFront上创建分发
  3. You add an origin to your distribution pointing to your bucket. 您将一个原点添加到指向您的存储桶的分发中。
  4. You make the default behavior of your distribution to grab content from the origin created on the previous step. 您可以使分发的默认行为从上一步创建的原点中获取内容。
  5. You change your distribution's settings to make it respond to your domain name, by adding a CNAME 您可以通过添加CNAME来更改分发的设置,使其响应您的域名
  6. You create a hosted zone on Route 53 and create ALIAS entries pointing to your distribution. 在Route 53上创建一个托管区域,并创建指向您的分发的ALIAS条目

That should work. 这应该工作。 By doing this, you have the added benefit of potentially improving performance for your end users. 通过这样做,您可以获得潜在改善最终用户性能的额外好处。

Also note that CloudFront has been included in the Free Tier a couple months ago ( http://aws.amazon.com/free ). 另请注意,几个月前CloudFront已包含在Free Tier中( http://aws.amazon.com/free )。

In my opinion, this is a tremendous design flaw in the way that S3 requires that bucket names are universally unique across all users. 在我看来,这是一个巨大的设计缺陷,因为S3要求存储桶名称在所有用户中都是唯一的。

I could, for example, make buckets for any well known company name (assuming they weren't taken) and then the legitimate users of those domains would be blocked from using them for the purpose of creating a static s3 website if they ever wanted to. 例如,我可以为任何知名公司名称制作存储桶(假设它们没有被采用),然后这些域的合法用户将被阻止使用它们,以便创建静态s3网站,如果他们想要。

I've never liked this requirement that s3 bucket names be unique across all users - a major design flaw (which I am sure had a legitimate reason when it was first designed), but can't imagine that if AWS could go back to the drawing board on this that they wouldn't re-think it now. 我从来没有喜欢过这样的要求:s3存储桶名称在所有用户中都是唯一的 - 这是一个主要的设计缺陷(我确信它在最初设计时有合理的原因),但无法想象如果AWS可以回到就此而言,他们不会重新思考它。

In your case, with a delete account, it is probably worth dropping a note to s3 tech support - they may be able to help you out quite easily. 在您的情况下,使用删除帐户,可能值得为s3技术支持删除注释 - 他们可能很容易帮助您。

I finally figured out a solution that worked for me. 我终于想出了一个对我有用的解决方案。 For my apex domain name I am using CloudFront which isn't an issue that someone already has my bucket name. 对于我的顶级域名,我使用的是CloudFront,这不是某人已拥有我的存储桶名称的问题。 The issue was the www redirect. 问题是www重定向。 I needed a server to rewrite the URL and issue a permanent redirect. 我需要一台服务器来重写URL并发出永久重定向。 Since I am using Elastic Beanstalk for my API I leveraged Nginx to accomplish the redirect. 由于我使用Elastic Beanstalk作为我的API,我利用Nginx来完成重定向。 You can read all the details on my post here: http://brettmathe.com/aws/aws-apex-redirect-using-elastic-beanstalk/ 您可以在此处阅读我的帖子中的所有详细信息: http//brettmathe.com/aws/aws-apex-redirect-using-elastic-beanstalk/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM