4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CloudFront構築時のハマりポイント

Posted at

構成

  • CloudFront → ALB → EC2となっている

代替ドメインを設定しようとするとCNAMEAlreadyExistsExceptionと出る

原因

  • CloudfrontのFQDNがRoute53でCNAMEで割り当てられているため起こっているみたい
  • 該当するCNAMEレコードを削除する
  • CNAMEではなくて、A(エイリアス)レコードで割り当てるのがよいっぽい
    • ただそのためには、CloudFrontの設定をUseAllEdgeLocationにしないといけない
      • それはバージニアリージョンでしか参照させることができないからみたい

502 The request could not be satisfied.

502 ERROR
The request could not be satisfied.
CloudFront wasn't able to connect to the origin. 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. 

原因その1

  • ALBに割り当てている証明書がエラーだったから
    • ALBのカスタムドメイン名がCommonNameに含まれているものではなく、まったく一致していない別物を当てていたから

原因その2

  • ALBを指定するOrigin Domain Nameが不適切だったというか、ALBの名前を指定していた
  • ここの答えは、ALBのカスタムドメイン名を指定する
    • image.png
    • ということは、Route53でエイリアスレコードやCNAMEレコードでALBを指定して、さらにALBにそのカスタムドメイン名がCommonNameに含まれているエラーを起こさない証明書を割り当てる必要がある

メモ

  • CloudFrontとALBを連携させる場合、証明書は2つ必要になる
    • ワイルドカード証明書でもいいかも
    • 東京リージョンで作っている場合それとは別に、CloudFrontに割り当てるためにバージニアリージョンでも取得する必要がある
      • ちなみにバージニアリージョンで取得する証明書はCloudFrontのAlias設定に割り当てる分必要

参考

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?