[英]Route 53 failover to s3 static web hosting not working
I have a website stage.example.com, I want to add a maintenance page for it,我有一个网站 stage.example.com,我想为它添加一个维护页面,
so I created a bucket with name stage.example.com, added a index document and then give it proper permissions, Now I can access this page using the url stage.example.com.s3.us-east.com.所以我创建了一个名为 stage.example.com 的存储桶,添加了一个索引文档,然后给它适当的权限,现在我可以使用 url stage.example.com.s3.us-east.com 访问这个页面。
for next step, I created a healthCheck
for stage.example.com
and as my server and website is dead and healthCheck also showing it is unhealthy, so I assume it is working fine.对于下一步,我创建了一个healthCheck
为stage.example.com
和我的服务器和网站是死的,健康检查也显示出它是不健康的,所以我认为这是工作的罚款。
Next step I changed my original record set's routing policy to fail over, changed TTL to 60s, associated healthCheck and make this record set primary.下一步,我将原始记录集的路由策略更改为故障转移,将 TTL 更改为 60 秒,关联 healthCheck 并将此记录集设为主记录集。
I created another record set with same name, make it a alias , chooses my s3 bucket, routing policy fail over and make it secondary record set.我创建了另一个具有相同名称的记录集,将其设为别名,选择我的 s3 存储桶,路由策略故障转移并使其成为辅助记录集。 As my website is already down, but I didn't redirected to my maintenance page.由于我的网站已经关闭,但我没有重定向到我的维护页面。
I have spent time to search for this issue, but couldn't find anything helpful.我花了一些时间来搜索这个问题,但找不到任何有用的东西。
Any help would be much appreciated.任何帮助将不胜感激。
I had the same problem when using CloudFormation template to create Route53 records with failover.使用 CloudFormation 模板创建带有故障转移的 Route53 记录时,我遇到了同样的问题。
Turns out that I was using entire s3 endpoint name in my template, rather than just its regional part.事实证明,我在模板中使用了整个 s3 端点名称,而不仅仅是其区域部分。 Let me explain using the template:让我解释一下使用模板:
app.cmcloudlab1073.info.s3-website-us-east-1.amazonaws.com app.cmcloudlab1073.info.s3-website-us-east-1.amazonaws.com
# Primary Alias record to ELB
MyRecordSet1:
Type: AWS::Route53::RecordSet
Properties:
AliasTarget:
DNSName: a05e-MyApp-7DUO60R115J5-258585633.us-east-1.elb.amazonaws.com
EvaluateTargetHealth: true
HostedZoneId: Z35SXDOTRQ7X7K
Failover: PRIMARY
HealthCheckId: !Ref MyR53HealthCheck
HostedZoneId: /hostedzone/Z2ETUSKZPW2K8B
Name: app.example.com # example domain for which record is created
SetIdentifier: elb-primary
Type: A
# Secondary record - a static s3 website
MyRecordSet2:
Type: AWS::Route53::RecordSet
Properties:
AliasTarget:
DNSName: ---> MY-ISSUE-WAS-HERE <----
EvaluateTargetHealth: false
HostedZoneId: Z3AQBSTGFYJSTF # for region us-east-1
Failover: SECONDARY
HostedZoneId: /hostedzone/Z2ETUSKZPW2K8B
Name: app.example.com # same name as for primary
SetIdentifier: s3-secondary
Type: A
MyR53HealthCheck:
Type: AWS::Route53::HealthCheck
Properties:
HealthCheckConfig:
FailureThreshold: 1
FullyQualifiedDomainName: a05e-MyApp-7DUO60R115J5-258585633.us-east-1.elb.amazonaws.com
MeasureLatency: false
Port: 80
RequestInterval: 10
ResourcePath: /
Type: HTTP
For the DNSName
in MyRecordSet2
I was using full s3 endpoint dns name for my static website:对于DNSName
中的MyRecordSet2
我为我的静态网站使用了完整的 s3 端点 dns 名称:
app.example.com.s3-website-us-east-1.amazonaws.com # <-- INCORRECT
The correct is only the s3 part:正确的只是s3部分:
s3-website-us-east-1.amazonaws.com # <-- CORRECT
As a side note, after the changed, failover worked perfectly.作为旁注,更改后,故障转移工作完美。 Did not need to restart any browsers.不需要重新启动任何浏览器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.