ELB for Envoy で Transit Gateway 越しの別 VPC の ALB へ HTTPS でリバースプロキシしてみた

ELB for Envoy で Transit Gateway 越しの別 VPC の ALB へ HTTPS でリバースプロキシしてみた

ELB for Envoy から別 VPC の ALB へ、通常の Transit Gateway 経由でも、CIDR が重複する VPC をつなぐ 1:1 NAT 経由でも、ホスト名を照合した HTTPS で転送できました。1:1 NAT では ALB の DNS 名だと接続がタイムアウトし、プライベートホストゾーンに変換後のアドレスを書くと接続できました。
2026.11.29

はじめに

2026年11月25日、Elastic Load Balancing for Envoy(ELB for Envoy)が GA になりました。

https://aws.amazon.com/about-aws/whats-new/2026/11/elastic-load-balancing-for-envoy-generally-available/

今回は、異なる VPC を AWS Transit Gateway(TGW)で接続し、別 VPC の internal ALB の HTTPS エンドポイントを ELB for Envoy 経由で利用できるかを検証しました。

あわせて、2つの VPC の CIDR が重複している場合を想定し、2026年10月に発表された AWS Transit Gateway と AWS Cloud WAN の 1:1 NAT 経由でも疎通を確認しています。

https://aws.amazon.com/about-aws/whats-new/2026/10/aws-transit-gateway-cloud-wan-1-1-nat/

検証環境

  • リージョン:東京(ap-northeast-1)
  • VPC
    • Envoy 側 VPC(Envoy と EC2 を置く):10.10.0.0/16
    • ALB 側 VPC(ALB を置く):10.20.0.0/16
    • 1:1 NAT の検証では、どちらの VPC も 10.30.0.0/16
    • サブネット:各 VPC に 1a と 1c の2つ(例:10.10.0.0/26 と 10.10.0.64/26。ほかの VPC も同じ形)
    • IGW と NAT ゲートウェイは置かず、SSM 用の VPC エンドポイント3つを使用
  • TGW
    • 既定のルートテーブル(アソシエーション、伝播とも有効)
  • ALB(ALB 側 VPC)
    • internal、HTTPS 443、固定応答
    • TLS ポリシー:ELBSecurityPolicy-TLS13-1-2-2021-06
    • 証明書:ACM の *.example.com
  • ELB for Envoy(Envoy 側 VPC)
    • Envoy:1.40(proxyVersion)
    • internal、2 AZ
  • EC2(Envoy 側 VPC)
    • t4g.nano(Amazon Linux 2023)
    • 操作:Systems Manager の Run Command

構成

EC2 から Envoy へは HTTP、Envoy から ALB へは HTTPS で接続します。

EC2 → ELB for Envoy(Envoy 側 VPC)→ TGW → ALB(ALB 側 VPC)

まず通常の TGW で疎通まで確認し、そのあとで 1:1 NAT に替えた場合の変更点を紹介します。

通常の Transit Gateway

ネットワークと ALB

IAM ロール aws-elb-proxy-role とプロキシの作成手順は、次の記事にあります。この記事では、ロールが作成済みの前提で進めます。

https://dev.classmethod.jp/articles/aws-elb-for-envoy-ga-create-proxy/

TGW を作成し、両 VPC のサブネット(1a と 1c)にアタッチメントを作成して、両 VPC のルートテーブルに相手の CIDR 宛てのルートを追加しました。TGW とアタッチメントは、作成後に状態が available になるのを待ってから、後続のコマンドを実行しました。

aws ec2 create-transit-gateway \
  --description "elbproxy-tgw phase1" \
  --options DefaultRouteTableAssociation=enable,DefaultRouteTablePropagation=enable \
  --tag-specifications 'ResourceType=transit-gateway,Tags=[{Key=Name,Value=elbproxy-tgw-phase1},{Key=Project,Value=elb-envoy-tgw-nat}]' \
  --query TransitGateway.TransitGatewayId --output text

aws ec2 create-transit-gateway-vpc-attachment \
  --transit-gateway-id <tgw-id> --vpc-id <envoy-vpc-id> \
  --subnet-ids <envoy-subnet-1a-id> <envoy-subnet-1c-id> \
  --tag-specifications 'ResourceType=transit-gateway-attachment,Tags=[{Key=Name,Value=<attachment-name>},{Key=Project,Value=elb-envoy-tgw-nat}]' \
  --query TransitGatewayVpcAttachment.TransitGatewayAttachmentId --output text

aws ec2 create-route --route-table-id <envoy-vpc-route-table-id> \
  --destination-cidr-block 10.20.0.0/16 --transit-gateway-id <tgw-id>
aws ec2 create-route --route-table-id <alb-vpc-route-table-id> \
  --destination-cidr-block 10.10.0.0/16 --transit-gateway-id <tgw-id>

ALB 側のアタッチメントは、VPC とサブネットを ALB 側のものに替えて同じ形で作成しました。

続けて、TGW の既定のルートテーブルを確認しました。

aws ec2 search-transit-gateway-routes --transit-gateway-route-table-id <tgw-route-table-id> \
  --filters Name=state,Values=active \
  --query 'Routes[].[DestinationCidrBlock,Type,TransitGatewayAttachments[0].TransitGatewayAttachmentId]' --output text
10.10.0.0/16	propagated	<envoy-attachment-id>
10.20.0.0/16	propagated	<alb-attachment-id>

ALB のセキュリティグループ(SG)は、Envoy 側 VPC の CIDR から TCP 443 を許可しました。プロキシの SG は、EC2 のある Envoy 側 VPC の CIDR から TCP 80 を許可しました。

aws ec2 authorize-security-group-ingress --group-id <alb-sg-id> --protocol tcp --port 443 --cidr 10.10.0.0/16 --output json
aws ec2 authorize-security-group-ingress --group-id <proxy-sg-id> --protocol tcp --port 80 --cidr 10.10.0.0/16 --output json

ALB は internal で、ALB 側 VPC の2つのサブネットに作成しました。リスナーは HTTPS 443 で、固定応答(service-b)を返します。

ALB のリスナー作成コマンド
aws elbv2 create-listener --load-balancer-arn <alb-arn> \
  --protocol HTTPS --port 443 \
  --certificates CertificateArn=<acm-certificate-arn> \
  --ssl-policy ELBSecurityPolicy-TLS13-1-2-2021-06 \
  --default-actions 'Type=fixed-response,FixedResponseConfig={StatusCode=200,ContentType=text/plain,MessageBody=service-b}' \
  --output json

名前解決と Envoy の設定

ALB の証明書(*.example.com)に合う名前で接続するため、Envoy 側 VPC に関連付けたプライベートホストゾーン(PHZ)を作り、ALB へのエイリアスレコードを作成しました。ゾーン名は、ドメイン全体の名前解決を上書きしないよう、ホスト名と同じ b-alb.example.com にしました。

aws route53 create-hosted-zone --name b-alb.example.com \
  --caller-reference <unique-string> \
  --vpc VPCRegion=ap-northeast-1,VPCId=<envoy-vpc-id> \
  --hosted-zone-config Comment=elbproxy-tgw,PrivateZone=true \
  --query HostedZone.Id --output text

aws route53 change-resource-record-sets --hosted-zone-id <hosted-zone-id> \
  --change-batch file://phz-change-phase1.json --output json

phz-change-phase1.json は次の内容です。

{
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "b-alb.example.com",
        "Type": "A",
        "AliasTarget": {
          "HostedZoneId": "<alb-hosted-zone-id>",
          "DNSName": "<alb-dns-name>",
          "EvaluateTargetHealth": false
        }
      }
    }
  ]
}

Envoy の設定は config-phase1.yaml として保存しました。クラスタは STRICT_DNS で、b-alb.example.com の 443 番ポートを指します。ELB for Envoy では、証明書のホスト名(SAN)の照合は、信頼する CA(trusted_ca)と組み合わせる必要があります。そのため validation_context では、trusted_ca に Amazon Root CA 1 を指定し、SAN を b-alb.example.com と照合する設定(match_typed_subject_alt_names)を書きました。

admin:
  address:
    socket_address:
      address: 127.0.0.1
      port_value: 9901
static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 80
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  cluster: service_b
                  auto_host_rewrite: true
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
  - name: service_b
    type: STRICT_DNS
    dns_lookup_family: V4_ONLY
    connect_timeout: 5s
    load_assignment:
      cluster_name: service_b
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: b-alb.example.com
                port_value: 443
    transport_socket:
      name: envoy.transport_sockets.tls
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
        sni: b-alb.example.com
        common_tls_context:
          validation_context:
            trusted_ca:
              inline_string: |
                <Amazon Root CA 1 の PEM>
            match_typed_subject_alt_names:
            - san_type: DNS
              matcher:
                exact: b-alb.example.com

プロキシは、create-proxy-input.json と config-phase1.yaml を渡して作成しました。

aws elb-proxy create-proxy --cli-input-json file://create-proxy-input.json \
  --cli-binary-format raw-in-base64-out \
  --configuration configurationFile=\{configurationBytes@=file://config-phase1.yaml\} \
  --output json
create-proxy-input.json
{
  "name": "tgw-proxy-phase1",
  "type": "envoy",
  "proxyVersion": "1.40",
  "roleArn": "arn:aws:iam::<account-id>:role/aws-elb-proxy-role",
  "networkConfiguration": {
    "ipConfiguration": {
      "ipAddressingConfiguration": { "ipv4Addressability": "internal", "ipv6Addressability": "off" }
    },
    "vpcConfiguration": {
      "subnets": [ { "subnetId": "<envoy-subnet-1a-id>" }, { "subnetId": "<envoy-subnet-1c-id>" } ],
      "securityGroups": [ { "securityGroupId": "<proxy-sg-id>" } ]
    }
  }
}

疎通結果

Envoy 側 VPC の EC2 で次のスクリプトを実行し、Envoy の DNS 名に HTTP で GET しました。

echo "--- getent hosts b-alb.example.com"
getent hosts b-alb.example.com
echo "--- curl proxy"
curl -sS -i --max-time 15 http://<proxy-dns-name>/
--- getent hosts b-alb.example.com
10.20.0.42      b-alb.example.com
10.20.0.82      b-alb.example.com
--- curl proxy
HTTP/1.1 200 OK
server: envoy
date: Sat, 28 Nov 2026 13:36:00 GMT
content-type: text/plain; charset=utf-8
content-length: 9
x-envoy-upstream-service-time: 37

service-b

同じ名前を公開 DNS(8.8.8.8)で引くと、NXDOMAIN が返りました。

dig b-alb.example.com @8.8.8.8 | grep -E 'status:'
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 22661

公開 DNS では解決できない名前を使って、Envoy が ALB 側 VPC の ALB に接続できました。

ALB の DNS 名を指定した場合

PHZ を使わず、address と sni、照合する SAN を ALB の DNS 名(<alb-dns-name>)に替えた設定に更新して、同じ操作を行いました。ALB の証明書は *.example.com のままです。

               socket_address:
-                address: b-alb.example.com
+                address: <alb-dns-name>
                 port_value: 443
 ...
-        sni: b-alb.example.com
+        sni: <alb-dns-name>
 ...
             match_typed_subject_alt_names:
             - san_type: DNS
               matcher:
-                exact: b-alb.example.com
+                exact: <alb-dns-name>
--- getent hosts <alb-dns-name>
10.20.0.42      <alb-dns-name>
10.20.0.82      <alb-dns-name>
--- curl proxy
HTTP/1.1 503 Service Unavailable
content-length: 98
content-type: text/plain
date: Sat, 28 Nov 2026 13:38:04 GMT
server: envoy

upstream connect error or disconnect/reset before headers. reset reason: remote connection failure

503 の原因は、SAN の照合です。match_typed_subject_alt_names の4行だけを削除し、trusted_ca を残した設定に更新すると、同じ操作で 200(service-b)が返りました。

1:1 NAT に替える

通常の TGW の環境を撤去し、Envoy 側 VPC と ALB 側 VPC の CIDR をどちらも 10.30.0.0/16 にして、新しい TGW で構成を作り直しました。この構成には、NAT ルール、変換後の CIDR を使うルートと SG、変換後のアドレスを返す名前解決を加えています。

NAT ルールの設定とルートの確認は、次の記事にもあります。この記事では、設定値と変更点を中心に載せます。

https://dev.classmethod.jp/articles/transit-gateway-1to1-nat-overlapping-cidr/

NAT ルールとルート

通常の TGW と同じ手順で両 VPC のアタッチメントを作成し、両方のアタッチメントに NAT ルールを設定しました。Envoy 側のアタッチメントでは 10.30.0.0/16 を 100.64.0.0/16 に、ALB 側のアタッチメントでは 10.30.0.0/16 を 100.65.0.0/16 に変換します。CIDR が同じ2つの VPC で片側だけ変換すると、ルールのない側は返信先を自 VPC 内のアドレスとして扱い、VPC のルートテーブルは、その通信を TGW へ出さず VPC 内に届けます。

https://docs.aws.amazon.com/vpc/latest/tgw/tgw-nat-how-it-works.html

NAT ルールの設定コマンドと確認結果
aws ec2 modify-transit-gateway-attachment-nat-configuration \
  --transit-gateway-attachment-id <envoy-attachment-id> \
  --nat-gateway-support enable \
  --nat-gateway-rules '[{"RuleNumber":100,"MatchSourceCidr":"10.30.0.0/16","NatCidr":"100.64.0.0/16"}]' \
  --output json

ALB 側のコマンドは、アタッチメント ID と NatCidr(100.65.0.0/16)以外が同じです。NatGatewaySupport が enabled になったことを確認してから、次の操作に進みました。

設定後にアタッチメントの NAT 設定を取得すると、次のようになりました(Envoy 側の例)。

aws ec2 get-transit-gateway-attachment-nat-configuration \
  --transit-gateway-attachment-id <envoy-attachment-id> --output json
{
    "TransitGatewayAttachmentId": "<envoy-attachment-id>",
    "NatGatewaySupport": "enabled",
    "NatSystemRouteSupport": "enable",
    "NatGatewayRules": [
        {
            "RuleNumber": 100,
            "MatchSourceCidr": "10.30.0.0/16",
            "NatCidr": "100.64.0.0/16",
            "State": "activated"
        }
    ]
}

TGW のルートテーブルも確認しました。

100.64.0.0/16	system	active	<envoy-attachment-id>
100.65.0.0/16	system	active	<alb-attachment-id>

VPC のルートの宛先は、相手側の変換後 CIDR です。Envoy 側 VPC のルートテーブルには ALB 側の変換後 CIDR 宛て、ALB 側 VPC のルートテーブルには Envoy 側の変換後 CIDR 宛てのルートを、TGW 向きに作成しました。10.30.0.0/16 は、どちらの VPC でも local のままです。

VPC のルートのコマンド
aws ec2 create-route --route-table-id <envoy-vpc-route-table-id> \
  --destination-cidr-block 100.65.0.0/16 --transit-gateway-id <tgw-id>
aws ec2 create-route --route-table-id <alb-vpc-route-table-id> \
  --destination-cidr-block 100.64.0.0/16 --transit-gateway-id <tgw-id>

ALB の SG は、Envoy 側 VPC の変換後 CIDR から TCP 443 を許可しました。プロキシの SG は、Envoy 側 VPC の CIDR 10.30.0.0/16 から TCP 80 を許可しました。

ALB の SG のコマンド
aws ec2 authorize-security-group-ingress --group-id <alb-sg-id> --protocol tcp --port 443 --cidr 100.64.0.0/16 --output json

名前解決と Envoy の設定

1:1 NAT は IP アドレスだけを変換し、DNS の応答を書き換えません。ホスト名は変換前のアドレスに解決されるので、変換後のアドレスを返す DNS レコードを用意します。

https://aws.amazon.com/blogs/networking-and-content-delivery/introducing-11-nat-on-aws-transit-gateway-and-aws-cloud-wan/

ALB ノードの実アドレスを取得し、変換後のアドレスに置き換えて、A レコードとして PHZ に登録しました。PHZ は、通常の TGW と同じく Envoy 側 VPC に関連付け、ゾーン名をホスト名と同じ d-alb.example.com にしました。

aws ec2 describe-network-interfaces \
  --filters "Name=description,Values=ELB app/<alb-name>/<alb-id>" \
  --query 'NetworkInterfaces[].PrivateIpAddress' --output text

ホスト部はそのままで、ネットワーク部を ALB 側の変換後 CIDR 100.65.0.0/16 に置き換えます。今回の ALB ノードは 10.30.0.51 と 10.30.0.76 で、変換後は 100.65.0.51 と 100.65.0.76 です。

aws route53 change-resource-record-sets --hosted-zone-id <hosted-zone-id> \
  --change-batch file://phz-change-phase2.json --output json

phz-change-phase2.json は次の内容です。値は、作成時点の ALB ノードのアドレスから作った固定値です。

{
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "d-alb.example.com",
        "Type": "A",
        "TTL": 60,
        "ResourceRecords": [{"Value":"100.65.0.51"},{"Value":"100.65.0.76"}]
      }
    }
  ]
}

Envoy の設定(config-phase2.yaml)は、config-phase1.yaml から次の6行を替えただけです。

-                  cluster: service_b
+                  cluster: service_d
 ...
-  - name: service_b
+  - name: service_d
 ...
-      cluster_name: service_b
+      cluster_name: service_d
 ...
-                address: b-alb.example.com
+                address: d-alb.example.com
 ...
-        sni: b-alb.example.com
+        sni: d-alb.example.com
 ...
-                exact: b-alb.example.com
+                exact: d-alb.example.com

疎通結果

Envoy 側 VPC の EC2 でも同じ形のスクリプトを実行し、Envoy の DNS 名に HTTP で GET しました。

--- getent hosts d-alb.example.com
100.65.0.76     d-alb.example.com
100.65.0.51     d-alb.example.com
--- curl proxy
HTTP/1.1 200 OK
server: envoy
date: Sat, 28 Nov 2026 13:53:01 GMT
content-type: text/plain; charset=utf-8
content-length: 9
x-envoy-upstream-service-time: 50

service-d

ALB の SG は 100.64.0.0/16 からの 443 だけを許可しています。この設定で 200 が返ったので、Envoy からの接続は変換後のアドレスで ALB に届いたことが分かります。

ALB の DNS 名を指定した場合

NAT ルールを両アタッチメントに設定した同じ構成を作り直しました。この確認は経路だけを見るため、SAN の照合を書かない設定(validation_context が system_root_certs だけ)を使い、address と sni を ALB の DNS 名(<alb-dns-name>)に替えて、同じ操作を行いました。PHZ は作っていません。

--- getent hosts <alb-dns-name>
10.30.0.52      <alb-dns-name>
10.30.0.121     <alb-dns-name>
--- curl proxy
HTTP/1.1 503 Service Unavailable
content-length: 91
content-type: text/plain
date: Sat, 28 Nov 2026 10:33:25 GMT
server: envoy

upstream connect error or disconnect/reset before headers. reset reason: connection timeout

ALB の DNS 名は、Envoy 側 VPC 自身と同じ CIDR の 10.30.0.x に解決されました。Envoy 側 VPC のルートでは 10.30.0.0/16 が local なので、この通信は TGW へ出ずに Envoy 側 VPC 内へ向かい、ALB に届かなかったと推測しています。

通常の TGW と 1:1 NAT の違い

項目 通常の TGW 1:1 NAT
TGW の追加設定 なし 両アタッチメントに NAT ルール
VPC のルートの宛先 相手の実 CIDR 相手の変換後 CIDR
ALB の SG の許可元 Envoy 側 VPC の実 CIDR Envoy 側 VPC の変換後 CIDR
ホスト名 ALB の DNS 名は SAN の照合で 503(remote connection failure)。PHZ の名前では 200 ALB の DNS 名では 503(接続タイムアウト。SAN の照合なしの設定)。PHZ に変換後アドレスの A レコードを登録すると 200

まとめ

ALB ノードのアドレスは変わります。今回の PHZ の A レコードは、作成時点の ALB ノードのアドレスから作った固定値です。そのため 1:1 NAT では、ALB の前段に固定 IP の NLB を置く構成が望ましいです。

ELB for Envoy → Transit Gateway(1:1 NAT)→ NLB → ALB

通常の Transit Gateway では、SAN の照合を省くと、PHZ なしで ALB の DNS 名を直接書けます。ただし、証明書に合わない名前でも接続できてしまうため、このリスクを許容できる場合に限ります。

集約 VPC に ELB for Envoy を置き、Transit Gateway 経由で別 VPC の ALB へ中継する仕組みを作るときの参考になればさいわいです。

この記事をシェアする

AWSのお困り事はクラスメソッドへ

関連記事