I own a domain example.com
, and want to host a static website in an S3 bucket on a subdomain of this, subdomain.example.com
.
我拥有一个域Example.com,并想在这个的子域subdomain.Example.com上的S3桶中托管一个静态网站。
I can view the website through the S3 static website endpoint and through the CloudFront domain endpoint but not when I go to my subdomain.
我可以通过S3静态网站终结点和CloudFront域终结点查看网站,但不能在转到我的子域时查看。
I have an S3 bucket called subdomain.example.com
which contains an index.html
file. It is a publicly-accessible bucket and when I go to the bucket properties, I can see a link, http://subdomain.example.com.s3-website.eu-west-2.amazonaws.com
, under "Static Website Hosting". Clicking this link allows me to view the site.
我有一个名为subdomain.example.com的S3存储桶,其中包含一个index.html文件。这是一个可公开访问的存储桶,当我转到存储桶属性时,我可以在“静态网站托管”下看到一个链接http://subdomain.example.com.s3-website.eu-west-2.amazonaws.com,。点击此链接,我可以查看该站点。
I have a CloudFront Distribution for this site configured as follows.
Under "Alternate Domain Names" I have subdomain.example.com
and when I go the CloudFront domain name, dXXXXXXXXXXXX.cloudfront.net
, I can view the site. This leads me to believe that there's some problem in the Route53 side of things.
我为此站点配置了一个CloudFront分发,如下所示。在“备选域名”下,我有subdomain.example.com,当我打开CloudFront域名dXXXXXXXXXX.cloudFront.net时,我可以查看该网站。这让我相信Route53方面存在一些问题。
I had previously registered the domain, example.com
, in Route53 and it has the name servers:
我之前在Route53中注册了域名Example.com,它的域名服务器是:
ns-1.awsdns-1.co.uk
,
ns-2.awsdns-2.com
,
ns-3.awsdns-3.org
,
ns-4.awsdns-4.net
.
I ensured that the hosted zone for example.com
had the same name servers.
I created a hosted zone for subdomain.example.com
and it had the following name servers:
我为subdomain.example.com创建了一个托管区域,该区域具有以下名称服务器:
ns-5.awsdns-5.co.uk
,
ns-6.awsdns-6.com
,
ns-7.awsdns-7.org
,
ns-8.awsdns-8.net
.
I then added an NS record into the hosted zone for example.com
with the aim of routing traffic to the name servers for subdomain.example.uk
:
然后,我将一条NS记录添加到Example.com的托管区域,目的是将流量路由到subdomain.example.uk的名称服务器:
- Name:
subdomain.example.uk
- Type: NS
- Routing Policy: Simple
- (Alias: No - can't be changed)
- Value/Route Traffic to:
ns-5.awsdns-5.co.uk
,ns-6.awsdns-6.com
,ns-7.awsdns-7.org
,ns-8.awsdns-8.net
- TTL: 86400
Lastly, I added an A and AAAA record into the hosted zone for subdomain.example.com
with the aim of routing traffic to the CloudFront distribution:
最后,我将A和AAAA记录添加到subdomain.example.com的托管区域,目的是将流量路由到CloudFront分发版:
- Name:
subdomain.example.uk
- Type: A
- Routing Policy: Simple
- Alias: Yes
- Value/Route Traffic to: Alias to CloudFront Distribution - my distribution appears and was selected
I'm expecting that when I go to subdomain.example.com
I'll see my website, but this doesn't happen.
我期待着当我访问subdomain.Example.com时,我会看到我的网站,但这并没有发生。
I've tried waiting for over an hour as CloudFront can take up to 25 minutes.
I've tried clearing the cache in my browser/using a different device.
After research, the common resolutions seem to be verifying that the hosted zone for the domain contains an NS record pointing to the name servers of the subdomain, and verifying that distribution was referenced in the Alias record.
我试着等了一个多小时,因为CloudFront可能需要25分钟。我已尝试清除浏览器中的缓存/使用不同的设备。经过研究,常见的解决方案似乎是验证域的托管区域是否包含指向子域的名称服务器的NS记录,以及验证别名记录中是否引用了分发。
I've read guides such as this CNAME guide and this CloudFront guide but I believe I've configured everything as described, or can't see what I'm missing.
I'm having a similar problem to this question, but am not getting an access denied error, rather an NS_ERROR_UKNOWN_HOST
when I view the Network tab in developer tools.
我已经阅读了诸如CNAME指南和CloudFront指南之类的指南,但我相信我已经按照描述配置了所有内容,或者看不到我遗漏了什么。我遇到了与此问题类似的问题,但当我在开发人员工具中查看网络选项卡时,我没有收到拒绝访问的错误,而是收到了NS_ERROR_UKNOWN_HOST。
It may be worth noting that I configured CloudFront to redirect HTTP requests to HTTPS and created a public certificate for *.subdomain.example.com
and subdomain.example.com
. When creating this, a CNAME record was added to subdomain.example.com
as well.
值得注意的是,我配置了CloudFront将HTTP请求重定向到HTTPS,并为 *. subdomain.example.com和subdomain.example.com创建了一个公共证书。在创建此文件时,还将CNAME记录添加到subdomain.example.com。
更多回答
I'm used to create a hosted zone for example.com and create a CNAME record for subdomain.example.com. Anyway what do you get when you run a command like dig subdomain.example.com
or enter this domain in a lookup site like this one.
我习惯于为Example.com创建一个托管区域,并为subdomain.Example.com创建一个CNAME记录。无论如何,当您运行一条命令,如dig subdomain.example.com或在这样的查找站点中输入此域时,您会得到什么。
@MarcC when I originally tried dig subdomain.example.com
I was just getting the same thing as when I tried through the browser. It's all working now though, thanks.
@Marcc当我最初尝试dig subdomain.Example.com时,我得到的结果与我通过浏览器尝试时的结果相同。不过,现在都能用了,谢谢。
我是一名优秀的程序员,十分优秀!