简体   繁体   English

设置Amazon SW3存储桶的dns,创建子域URL路由器Amazon S3

[英]Setting up the dns of amazon sw3 bucket, creating subdomain url router amazon s3

I have a repository bucket on amazon. 我在亚马逊上有一个存储桶。 In this repository I have a page, with only css, js and html, I start the application with the index.html. 在此存储库中,我只有一个页面,仅包含css,js和html,我使用index.html启动应用程序。

The application url is available, and look like this : 该应用程序的URL可用,如下所示:

example.s3-aws-region.amazonaws.com. 

I want to redirect all subdomain of the url to the url application, for example if I go to the following url I want to redirect to the url of the app : 我想将url的所有子域重定向到url应用程序,例如,如果我转到以下url,我想重定向到该应用程序的url:

bucket.example.s3-aws-region.amazonaws.com
subdomain.example.s3-aws-region.amazonaws.com
subdomain_2.example.s3-aws-region.amazonaws.com

(Note that the domain is provided by amazon, not a personal domain) (请注意,域名是由亚马逊提供的,而不是个人域名)

So, I need to edit the dns and create a CNAME record. 因此,我需要编辑dns并创建一个CNAME记录。 I tried creating a host zone, and then I created a CNAME record with the following value *.example.s3-aws-region.amazonaws.com 我尝试创建一个宿主区域,然后创建了一个具有以下值* .example.s3-aws-region.amazonaws.com的CNAME记录

But it didn't work 但这没用

How can I do it? 我该怎么做?

You cannot do this using CNAME entries because you do not own the amazonaws.com domain. 您不能使用CNAME条目执行此操作,因为您不拥有amazonaws.com域。

Instead, you can use multiple buckets along with 301 redirects. 相反,您可以使用多个存储桶以及301重定向。

  1. Create your main bucket, let's assume it's called example . 创建您的主存储桶,假设它被称为example
  2. Create a second bucket called subdomain.example . 创建另一个名为subdomain.example存储桶。
  3. On subdomain.example , configure "Static Website Hosting" to "Redirect all requests to another host name" using example.s3-website-region.amazonaws.com as the target. subdomain.example ,使用example.s3-website-region.amazonaws.com作为目标,将“静态网站托管”配置为“将所有请求重定向到另一个主机名”。

Then, in your browser, if you go to subdomain.example.s3-website-region.amazonaws.com , you will be 301 redirected to example.s3-website-region.amazonaws.com . 然后,在浏览器中,如果转到subdomain.example.s3-website-region.amazonaws.com ,您将被301重定向到example.s3-website-region.amazonaws.com

Note that this is a 301 redirect, it's not a CNAME or an alias. 请注意,这是301重定向,不是CNAME或别名。 So the redirect will be visible in the browser address bar. 因此重定向将在浏览器地址栏中可见。

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

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