静态托管在亚马逊S3 - DNS配置亚马逊、静态、DNS

2023-09-11 23:37:23 作者:蒲公英的浅笑

我工作的一个小的web应用(所有客户端),我想主持它在Amazon S3。我已经发现了几个导游在这一点,并已成功地创建自己的水桶(具有相同的名称作为我的域),将其设置为一个网站,并上传一些内容。

I'm working on a little webapp (all client-side) I want to host it on Amazon S3. I've found several guides on this and have managed to create myself a bucket (with the same name as my domain), set it as a website and upload some content.

当我挣扎,并在所有文件开始变得有点模糊,是如何正确配置我的DNS。

Where I'm struggling, and where all the documentation starts to get a bit vague, is how to properly configure my DNS.

我所有的注册机构( 123章)可以建议是网络转发这给了我mydomain.com.s3.amazonaws.com

All my registrar (123-reg) could suggest was web forwarding which gives me mydomain.com.s3.amazonaws.com

我有什么配置,并在(即123寄存器/亚马逊)我可以得到一个干净的网址是什么?

What do I have to configure, and where (ie. 123-reg / Amazon) can I get a clean URL?

推荐答案

听起来像是你所做的大部分工作已经。为了清楚起见,我会去对这些步骤重新只是为了确保你正确设置:

Sounds like you've done most of the work already. For clarity I'll go over those steps again just to make sure you're set up properly:

使用您的域名作为bucket名称创建一个S3桶(你的水桶名称应为www.example.com如果你想让你的网站是example.com或www.example.com)

Create an s3 bucket using your domain name as the bucket name (your bucket name should be www.example.com if you want your site to be example.com or www.example.com)

上传内容到S3桶。为您的网站索引文件选择一个一致的名称(通常的index.html)。您也可以上传自定义页面404未找​​到错误。调用此404.html。给读取权限,每个文件在你的网站,让市民可以查看它。不要给内任何额外的权限斗,只是将文件。

Upload your content to the s3 bucket. Choose a consistent name for your website index files (index.html usually). You can also upload a custom page for 404 Not Found errors. Call this 404.html. Give Read permissions to every file in your website so that the public can view it. Don't give any extra permissions to the bucket, just the files within.

配置你的水桶作为一个网站。随着AWS控制台( https://console.aws.amazon.com/s3/ ),你可以选择你的水桶,点击属性,然后选择网站选项卡。单击启用,并设置你的索引文件index.html的和你的错误文档404.html。您还需要设置你的水桶具有访问权限,允许通过Web访问(http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteAccessPermissionsReqd.html)

Configure your bucket as a website. With the AWS console ( https://console.aws.amazon.com/s3/ ) you can select your bucket, click properties, then select the "Website" tab. Click enabled and set your index document to "index.html" and your error document to "404.html". You will also need to set your bucket with access permissions to allow access via the web (http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteAccessPermissionsReqd.html)

请记下端点网址的网站配置选项卡。这是你的网站的生活。你可以打开一个新窗口的链接,你会看到你的网站就如同它的外观。点击周围,并确保一切运行正常。

Take a note of the "Endpoint" URL in the website configuration tab. This is where your website lives. You can open the link in a new window and you should see your website just as it will look. Click around and make sure everything works as expected.

您必须使用的端点地址在下面的所有步骤。正常www.example.com.s3.amazonaws.com将无法正常工作 - 你需要使用区域版本(http://www.example.com.s3-website-us-east-1.amazonaws.com/ )

You MUST use the endpoint address in all steps below. The normal www.example.com.s3.amazonaws.com won't work - you need to use the regional version (http://www.example.com.s3-website-us-east-1.amazonaws.com/)

现在,我们可以设置DNS来给你一个干净的,自定义的URL。

Now, we can set up the DNS to give you a clean, custom URL.

首先,我们将映射www.example.com到你的网站。

First, we will map www.example.com to your site.

使用您的DNS提供商的工具,(123章你的情况),你需要创建一个CNAME记录映射www.example.com到www.example.com.s3-网站 - 美东1.amazonaws。 COM

Using your DNS provider's tools, (123-reg in your case) you need to create a CNAME record to map www.example.com to www.example.com.s3-website-us-east-1.amazonaws.com

的CNAME是你需要的,如果你只是想www.example.com的唯一的事。大多数人还希望example.com的工作,所以我们需要迈出的又一步。

The CNAME is the only thing you need if you just want www.example.com. Most people also want "example.com" to work so we need another step.

example.com常被称为裸域或域的顶点记录。所述RESON它的一个问题是,它不能是一个CNAME。的CNAME只能在像子域的www。这使得更难以在点S3

example.com is often referred to as a naked domain or the apex record of the domain. The reson it's a problem is that it can't be a CNAME. CNAMEs only work on subdomains like "www." This makes it more difficult to point at s3.

通常的方法是使用服务自动重定向任何请求要example.com指向www.example.com。这将然后拿起您的CNAME记录,将您的网站从S3送达。

The usual approach is to use a service to automatically redirect any request going to example.com to point to www.example.com. This will then pick up your CNAME record and your site will be served from s3.

所以你必须使用其他服务的自动重定向是不可能与普通的旧的DNS。一些DNS提供商连同他们的DNS提供此项服务(GoDaddy的那样,亚马逊route53没有。不知道大约123-REG)

The automatic redirect is not possible with plain old DNS so you have to use another service. Some DNS providers offer this service along with their DNS (godaddy does, amazon route53 does not. Not sure about 123-reg)

如果您的DNS提供商不这样做,也有一些免费的服务。一说,我用的是 http://wwwizer.com/naked-domain-redirect - 它不需要任何注册或付款。

If your DNS provider doesn't do it, there are a few free services. One that I've used is http://wwwizer.com/naked-domain-redirect - it doesn't require any registration or payment.

要使用这种类型的服务,您需要创建一个DNSA记录您的裸域。对于wwwizer.com服务,你需要创建一个A记录指向example.com到174.129.25.170。这就是全部!

To use this type of service, you need to create a DNS "A" record for your naked domain. For the wwwizer.com service, you would need to create an A record to point example.com to 174.129.25.170. That's all!

所以,用这种设置,如果用户键入example.com到他们的浏览器,下面会发生什么:

So, with this setup, if a user types example.com into their browser, the following would happen:

DNS查询:example.com - > 174.129.25.170(wwwizer.com的服务) 在HTTP请求发送到174.129.25.170为example.com 174.129.25.170重定向example.com - > www.example.com DNS查询:www.example.com - > CNAME到www.example.com.s3-website-us-east-1.amazonaws.com DNS查询:www.example.com.s3-website-us-east-1.amazonaws.com - >点到Amazon S3 为www.example.com HTTP请求,现在由亚马逊S3服务

享受!