1
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.

AWS Route53を使ったGithub Pagesのカスタムドメイン設定

Posted at

Prerequisite

自分でGithub Pagesを持っている

自分のドメインをGithub Pagesに設定する

1. Domain購入

お名前ドットコムで買った。

nakamasato.com

2. Github PagesのDomain設定

この中でDNSレコードの設定があるので、AWSのRoute53を使用

3. AWSのRoute53でHostedZone作成 (Terraform)

  1. Route53のゾーンとレコードを作成

    Terraform の場合:

    main.tf
    resource "aws_route53_zone" "nakamasato-com" {
      name    = "nakamasato.com"
      comment = "my domain"
      tags = {
        Environment = "test"
      }
    }
    
    resource "aws_route53_record" "about" {
      zone_id = aws_route53_zone.nakamasato-com.zone_id
      name    = "about"
      type    = "CNAME"
      ttl     = "5"
    
      records = ["nakamasato.github.io"]
    }
    

    cliの場合:

    aws route53 create-hosted-zone --name nakamasato.com --caller-reference 2021-10-24-12:10
    

    --caller-reference は失敗したときに同じRequestをRetryしてくれる用の uniqueなString

    route53.json
    {
      "Comment": "create record for about",
      "Changes": [
        {
          "Action": "CREATE",
          "ResourceRecordSet": {
            "Name": "about.nakamasato.com.",
            "Type": "CNAME",
            "TTL": 5,
            "ResourceRecords": [
              {
                "Value": "nakamasato.github.io"
              }
            ]
          }
        }
      ]
    }
    
    aws route53 change-resource-record-sets --hosted-zone-id ZXXXXXXXXXX --change-batch file://route53.json
    
  2. Domain設定でネームサーバをdns1.onamae.comからroute53のネームサーバへ切り替える
    Screen Shot 2021-06-20 at 17.49.05.png

  3. 確認

    nslookup -type=ns nakamasato.com
    Server:         192.168.3.1
    Address:        192.168.3.1#53
    
    Non-authoritative answer:
    nakamasato.com  nameserver = ns-437.awsdns-54.com.
    nakamasato.com  nameserver = ns-1430.awsdns-50.org.
    nakamasato.com  nameserver = ns-2010.awsdns-59.co.uk.
    nakamasato.com  nameserver = ns-696.awsdns-23.net.
    
    Authoritative answers can be found from:
    ns-437.awsdns-54.com    internet address = 205.251.193.181
    ns-696.awsdns-23.net    internet address = 205.251.194.184
    ns-1430.awsdns-50.org   internet address = 205.251.197.150
    ns-2010.awsdns-59.co.uk internet address = 205.251.199.218
    
  4. about.nakamasato.com を Github Pagesに設定 + Enforce HTTPS をクリック

    スクリーンショット 2021-10-24 12.33.01.png

  5. https://about.nakamasato.com
    Screen Shot 2021-06-20 at 17.48.22.png

Route53の料金

個人で使う場合はTrafficも少ないと思うので、以下の2つで良さそうなので、月1ドルくらいを想定

  • 0.50USD ホストゾーンごと /月
  • 0.40USD 100 万クエリごと

参考

1
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
1
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?