gpt4 book ai didi

aws-cloudformation - Cloudfront 的自定义 DNS 返回 403

转载 作者:行者123 更新时间:2023-12-03 07:23:44 26 4
gpt4 key购买 nike

我正在使用 Cloudformation 来部署资源。这包括 Cloudfront CDN 和 RecordSet。我希望为自定义域 test.example.com 创建一个新记录集,该记录集将指向我的 Cloudfront CDN,而该 CDN 又指向 S3 存储桶。部署成功后,出现以下错误:

403 ERROR
The request could not be satisfied.
Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

使用 Cloudfront 域进行测试成功。当我检查 AWS 控制台时,我唯一注意到的是备用域名 (CNAME) 为空: enter image description here

当我用预期值 test.example.com 填充该值时,页面加载得很好。我尝试将 Aliases: test.example.com 添加到 Cloudfront DistributionConfig 但随后我收到 RecordSet 的循环错误。

如何在 Cloudformation 中同时拥有 CDN 和记录集,并填充备用域名 (CNAME)?

云前端:

  Distribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Origins:
-
# Use the Website as the origin
DomainName: !GetAtt 'Website.DomainName'
Id: !Ref Website
S3OriginConfig:
OriginAccessIdentity: !Join [ '', [ 'origin-access-identity/cloudfront/', !Ref CloudFrontOriginAccessIdentity] ]
Enabled: true
HttpVersion: http2
DefaultRootObject: index.html
CustomErrorResponses:
- ErrorCode: 404
ResponseCode: 200
ResponsePagePath: /index.html
- ErrorCode: 403
ResponseCode: 200
ResponsePagePath: /index.html
DefaultCacheBehavior:
AllowedMethods:
- DELETE
- GET
- HEAD
- OPTIONS
- PATCH
- POST
- PUT
DefaultTTL: 60
ForwardedValues:
QueryString: true
Cookies:
Forward: none
# The origin id defined above
TargetOriginId: !Ref Website
ViewerProtocolPolicy: "redirect-to-https" # we want to force https
# The certificate to use when using https
ViewerCertificate:
AcmCertificateArn: arn:aws:acm:us-east-1:<id>:certificate/<certId>
MinimumProtocolVersion: TLSv1
SslSupportMethod: sni-only

DNS:

  DNS:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneId: <<id>>
RecordSets:
- Name: test.example.com
Type: A
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt
- Distribution
- DomainName

最佳答案

当我将以下内容添加到 Cloudfront 发行版时,看起来似乎成功了:

Aliases:
- test.example.com

我的错误是我之前引用了 DNS:

Aliases: !Ref DNS

这是不正确的并导致我的循环依赖问题

关于aws-cloudformation - Cloudfront 的自定义 DNS 返回 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65758094/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com