AWS TLS(SSL)設定(ロードバランサ)

Tech Knowledge
公開: 2023-02-06

(1) ターゲットグループの作成

EC2 ダッシュボード > 左側メニューのロードバランシング > ターゲットグループ
https://ap-northeast-1.console.aws.amazon.com/ec2/home?region=ap-northeast-1#TargetGroups:

「Create target group」ボタン押下

Basic configuration

  • Choose a target type IP addresses を選択

  • Target group name 名前(必須)(A maximum of 32 alphanumeric characters including hyphens are allowed, but the name must not begin or end with a hyphen.)

  • Protocol: TCP(HTTP、HTTPS ではない)

  • Port: 80

  • VPC VPCを選択

「Next」ボタン押下

Register targets

  • IPv4 address ローカルIPを設定

「Include as pending below」ボタン押下 「Create target group」ボタン押下

※クライアントIPアドレスをWebサーバーに連携する場合は Preserve client IP addresses をオン
X-Forwarded-For ヘッダは生成されない

(2) ロードバランサ―の作成

EC2 ダッシュボード > 左側メニューのロードバランシング > ロードバランサ― https://ap-northeast-1.console.aws.amazon.com/ec2/home?region=ap-northeast-1#LoadBalancers:

「Create load balancer」ボタン押下

Create Network Load Balancer

  • Select load balancer type Network Load Balancer > Create

Basic configuration

  • Load balancer name ロードバランサーの名称を設定(A maximum of 32 alphanumeric characters including hyphens are allowed, but the name must not begin or end with a hyphen.)
  • Scheme Internet-facing
  • IP address type IPv4

Network mapping

  • VPC VPC を選択
  • Mappings Subnet を選択

Listeners and routing

  • Protocol: TLS
  • Port: 443
  • Default Action (1) で作成したターゲットグループを選択
  • 「Create load balancer」ボタン押下

(3) DNSにロードバランサを設定

Route 53 > ホストゾーン
該当ホストゾーン名(DNS名)を選択 > レコードを作成
レコード名: 空
レコードタイプ: A
エイリアス: ON
トラフィックのルーティング先: (2) で作成したロードバランサのDNS名を設定 > 「レコードを作成」

参考 ELB ロードバランサーへのトラフィックのルーティング