
Elastic Load Balancing for Envoy がリリースされたので試してみた
はじめに
2026年11月25日に、Elastic Load Balancing (ELB) for Envoy の一般提供が発表されました。
ELB for Envoy は、オープンソースの Envoy を AWS がマネージドサービスとして提供するロードバランサーで、任意のエンドポイントへのリバースプロキシとして使えます。
この記事では、ELB for Envoy を作成し、バックエンドへの転送と振り分け、ACM 証明書による HTTPS 終端、Lua フィルターを試した結果を紹介します。
検証環境
- リージョン:東京(ap-northeast-1)
- aws-cli:2.42.4
- プロキシのバージョン:1.40
プロキシの作成
ELB for Envoy は、EC2 コンソールのロードバランサー作成画面(ロードバランサータイプの比較と選択)に、Application Load Balancer などと並んで追加されています。この記事では CLI で作成しました。

前提リソース
プロキシの作成には、IAM ロール、2つの AZ にサブネットを持つ VPC、セキュリティグループ(SG)が必要です。ロールと SG は次のコマンドで作りました。
ロールと SG の作成コマンド
ロールの信頼ポリシーのプリンシパルは elasticloadbalancing.amazonaws.com です。権限は、CloudWatch Logs の /aws/elb-proxy/ 配下への書き込みだけを付けました。
trust-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "elasticloadbalancing.amazonaws.com" },
"Action": "sts:AssumeRole"
}
]
}
logs-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": [
"arn:*:logs:*:*:log-group:/aws/elb-proxy/*",
"arn:*:logs:*:*:log-group:/aws/elb-proxy/*:log-stream:*"
]
}
]
}
aws iam create-role \
--role-name aws-elb-proxy-role \
--assume-role-policy-document file://trust-policy.json \
--output json
aws iam put-role-policy \
--role-name aws-elb-proxy-role \
--policy-name aws-elb-proxy-logs \
--policy-document file://logs-policy.json
aws ec2 create-security-group \
--group-name elb-proxy-verify \
--description "ELB for Envoy verification" \
--vpc-id <vpc-id> \
--output json
aws ec2 authorize-security-group-ingress \
--group-id <security-group-id> \
--ip-permissions \
'IpProtocol=tcp,FromPort=80,ToPort=80,IpRanges=[{CidrIp=<your-ip>/32,Description=verify}]' \
'IpProtocol=tcp,FromPort=443,ToPort=443,IpRanges=[{CidrIp=<your-ip>/32,Description=verify}]' \
--output json
設定ファイルと作成コマンド
create-proxy に渡す入力は、次の create-proxy-input.json です。internet-facing の IPv4 で、2つのサブネットと SG を指定します。
{
"name": "verify-proxy",
"type": "envoy",
"proxyVersion": "1.40",
"roleArn": "arn:aws:iam::123456789012:role/aws-elb-proxy-role",
"networkConfiguration": {
"ipConfiguration": {
"ipAddressingConfiguration": { "ipv4Addressability": "internet-facing", "ipv6Addressability": "off" }
},
"vpcConfiguration": {
"subnets": [ { "subnetId": "<subnet-id-1>" }, { "subnetId": "<subnet-id-2>" } ],
"securityGroups": [ { "securityGroupId": "<security-group-id>" } ]
}
}
}
最初のプロキシには、getting-started のサンプル設定をそのまま使いました。ポート 80 で固定の文字列を返す設定です。
config-01-direct-response.yaml
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: "/"
direct_response:
status: 200
body:
inline_string: "Your proxy is running\n"
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
設定ファイルは、--configuration の configurationBytes に渡します。
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-01-direct-response.yaml} \
--output json
応答の status は create-in-progress で、dnsName は <proxy-name>-<ID>.elb-proxy.ap-northeast-1.on.aws の形でした。応答の arn は、以降のコマンドの --proxy-identifier に渡します。この記事では <proxy-arn> と書きます。
起動までの時間と応答
作成の受付から約3分20秒後に、get-proxy で status が active になったことを確認できました。
aws elb-proxy get-proxy --proxy-identifier <proxy-arn> --output json
active になった後、DNS 名へ curl でリクエストを送ると、次の応答が返りました。
$ curl -sS -i --max-time 15 http://<dns-name>/
HTTP/1.1 200 OK
content-length: 22
content-type: text/plain
date: Thu, 26 Nov 2026 04:32:47 GMT
server: envoy
Your proxy is running
バックエンドへの転送
リバースプロキシとして動かす検証では、同じ手順で2台目(verify-proxy-2)を作り、バックエンドへ転送しました。
外部ホストへの中継
2台目の入力 create-proxy-input-2.json は、1台目の入力から name(verify-proxy-2)と securityGroupId だけを変えたものです。
config-09-checkip.yaml は、config-01 の固定応答(direct_response)を、バックエンド checkip.amazonaws.com への転送に変えたものです。
route では、次の2つを指定しています。
- cluster: checkip で、転送先の cluster を指定します
- auto_host_rewrite: true で、Envoy が checkip.amazonaws.com へ送るリクエストの Host ヘッダーを、checkip.amazonaws.com に上書きします
routes:
- match:
prefix: "/"
route:
cluster: checkip
auto_host_rewrite: true
clusters には、バックエンドのアドレスを書いています。
clusters:
- name: checkip
type: STRICT_DNS
dns_lookup_family: V4_ONLY
connect_timeout: 5s
load_assignment:
cluster_name: checkip
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: checkip.amazonaws.com
port_value: 80
2つのファイルを create-proxy に渡して、2台目を作成しました。
aws elb-proxy create-proxy \
--cli-input-json file://create-proxy-input-2.json \
--cli-binary-format raw-in-base64-out \
--configuration configurationFile={configurationBytes@=file://config-09-checkip.yaml} \
--output json
バックエンドの応答が、そのままクライアントへ返りました。本文の IP アドレスは、Envoy の IP アドレスでした。
$ curl -si --max-time 20 http://<dns-name>/
HTTP/1.1 200 OK
content-type: text/plain;charset=UTF-8
server: envoy
x-envoy-upstream-service-time: 134
<proxy-ip-1>
この IP アドレスは、プロキシの DNS 名の A レコード(AZ ごとに1つ、合わせて2件)のどちらかでした。curl の --resolve で接続先の IP アドレスを固定すると、checkip が返した IP アドレスは接続先と同じでした。
Lambda 関数 URL への転送
AWS 上のリソースをバックエンドにする例として、Lambda 関数 URL への転送を試しました。
バックエンドには、認証なし(AuthType NONE)の関数 URL を付けた Python 3.13 の Lambda 関数を2つ(A、B)使いました。関数は origin=<A または B> path=<受け取ったパス> を返します。以降の表の origin=A と origin=B は、この応答です。
Lambda を IAM 認証で呼び出すフィルターも提供されていますが、今回は認証なしの関数 URL を利用しました。
バックエンドへ TLS で接続する cluster は次のとおりです。lambda_b は、ホスト名以外は同じです。
- name: lambda_a
type: STRICT_DNS
dns_lookup_family: V4_ONLY
connect_timeout: 5s
load_assignment:
cluster_name: lambda_a
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: <lambda-a-host>
port_value: 443
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: <lambda-a-host>
common_tls_context:
validation_context:
system_root_certs: {}
この cluster に SAN の照合は書いていません。エンドポイントのホスト名が証明書と一致しなくても接続できる状態で検証しています。
ヘッダーとパスによる振り分け
振り分けは、listener は config-09、cluster は上の lambda_a と lambda_b を共通で使い、routes だけを変えた3つの設定で試しました。
User-Agent のようなリクエストヘッダーの値も、振り分けの条件にできます。config-10a-user-agent.yaml は、User-Agent に curl が含まれれば lambda_a へ、それ以外は lambda_b へ転送します。route は上から順に評価され、最初に一致したものが使われます。
routes:
- match:
prefix: "/"
headers:
- name: user-agent
string_match:
contains: curl
route:
cluster: lambda_a
auto_host_rewrite: true
- match:
prefix: "/"
route:
cluster: lambda_b
auto_host_rewrite: true
パス / へ、User-Agent を変えてリクエストを送りました。curl の User-Agent は curl/8.18.0 で、別の User-Agent は -A "Mozilla/5.0" で指定しました。
| User-Agent | 応答の本文 |
|---|---|
| curl | origin=A path=/ |
| Mozilla | origin=B path=/ |
config-10b-path.yaml は、パスが /a/ で始まれば lambda_a、/b/ で始まれば lambda_b へ転送します。どちらにも当たらないリクエストには、direct_response で 404 を返します。
routes:
- match:
prefix: "/a/"
route:
cluster: lambda_a
auto_host_rewrite: true
prefix_rewrite: "/"
- match:
prefix: "/b/"
route:
cluster: lambda_b
auto_host_rewrite: true
- match:
prefix: "/"
direct_response:
status: 404
body:
inline_string: "no route\n"
User-Agent が curl のリクエストを、次のパスへ送りました。
| パス | 応答の本文 |
|---|---|
| /a/hello | origin=A path=/hello |
| /b/hello | origin=B path=/b/hello |
| /c/hello | 404 no route |
| /a | 404 no route |
| /b | 404 no route |
prefix_rewrite を付けた /a/ の route では、バックエンドへ渡るパスが /a/hello から /hello に変わります。付けていない /b/ の route では、元のパス /b/hello のまま渡ります。/a と /b は末尾のスラッシュがないため、/a/ と /b/ の route に当たらず、404 になります。
config-10c-combined.yaml は、/a/ へのリクエストを User-Agent で A と B に分ける設定です。
config-10c-combined.yaml の route
routes:
- match:
prefix: "/a/"
headers:
- name: user-agent
string_match:
contains: curl
route:
cluster: lambda_a
auto_host_rewrite: true
prefix_rewrite: "/"
- match:
prefix: "/a/"
route:
cluster: lambda_b
auto_host_rewrite: true
prefix_rewrite: "/"
- match:
prefix: "/"
direct_response:
status: 404
body:
inline_string: "no route\n"
| パス | User-Agent | 応答の本文 |
|---|---|---|
| /a/hello | curl | origin=A path=/hello |
| /a/hello | Mozilla | origin=B path=/hello |
| /b/hello | curl | 404 no route |
JWT のクレームによる振り分け
jwt_authn でトークンを検証し、クレームの値をリクエストヘッダーに設定して、route で A と B を切り替える設定も試しました。config-11-1b-jwt-clear-route-cache.yaml の cluster は config-10a と同じです。
route は x-tenant ヘッダーの値で振り分けます。値が a なら lambda_a、b なら lambda_b へ転送し、それ以外には direct_response で 403 を返します。
routes:
- match:
prefix: "/"
headers:
- name: x-tenant
string_match:
exact: a
route:
cluster: lambda_a
auto_host_rewrite: true
- match:
prefix: "/"
headers:
- name: x-tenant
string_match:
exact: b
route:
cluster: lambda_b
auto_host_rewrite: true
- match:
prefix: "/"
direct_response:
status: 403
body:
inline_string: "unknown tenant\n"
jwt_authn は router の前に置きます。local_jwks に HS256 の対称鍵(使い捨て)をインラインで指定した設定の更新は、受理されました。claim_to_headers で tenant クレームを x-tenant ヘッダーへ出しています。
- name: envoy.filters.http.jwt_authn
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.jwt_authn.v3.JwtAuthentication
providers:
verify_provider:
issuer: verify-issuer
local_jwks:
inline_string: '{"keys":[{"kty":"oct","alg":"HS256","kid":"verify-key","k":"<base64url-secret>"}]}'
claim_to_headers:
- header_name: x-tenant
claim_name: tenant
clear_route_cache: true
rules:
- match:
prefix: "/"
requires:
provider_name: verify_provider
トークンは、Authorization: Bearer ヘッダーで送りました。結果は次のとおりです。
| リクエスト | 応答 |
|---|---|
| tenant=a のトークン | origin=A path=/hello |
| tenant=b のトークン | origin=B path=/hello |
| tenant=x のトークン | 403 unknown tenant |
設定更新
ここからは1台目(verify-proxy)に戻り、update-proxy-configuration で Lua フィルターと HTTPS リスナーを追加します。
Lua フィルターの追加
config-02-lua.yaml は、config-01 の http_filters の先頭に Lua フィルターを足したものです。追加した Lua フィルターは次のとおりです。
- name: envoy.filters.http.lua
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
default_source_code:
inline_string: |
function envoy_on_response(response_handle)
response_handle:headers():add("x-verify-lua", "hello-from-lua")
end
aws elb-proxy update-proxy-configuration \
--proxy-identifier <proxy-arn> \
--cli-binary-format raw-in-base64-out \
--configuration-file configurationBytes@=file://config-02-lua.yaml \
--output json
更新後の応答には、更新前になかった x-verify-lua ヘッダーが付きました。
$ curl -sS -i --max-time 15 http://<dns-name>/
HTTP/1.1 200 OK
content-length: 22
content-type: text/plain
x-verify-lua: hello-from-lua
server: envoy
date: Thu, 26 Nov 2026 04:33:15 GMT
Your proxy is running
ACM 証明書による HTTPS 終端
ACM の証明書は、プロキシと同じアカウントとリージョンのものを使います。プロキシへの関連付けは呼び出し元の認証情報で行われます。そのため、associate-certificate を実行する IAM プリンシパルに、対象の証明書に対する acm:CreateCertificateRelation の権限が必要です。
今回は、ACM が発行したワイルドカード証明書(*.example.com)を使いました。この証明書をプロキシへ関連付けます。証明書の ARN を参照する設定更新は、関連付けが active になってから行います。
aws elb-proxy associate-certificate \
--proxy-identifier <proxy-arn> \
--certificate-identifier arn:aws:acm:ap-northeast-1:123456789012:certificate/<certificate-id> \
--output json
応答の status は associate-in-progress でした。list-certificate-associations を3秒ごとに確認すると、受付から約3秒後の確認で active になっていました。
aws elb-proxy list-certificate-associations --proxy-identifier <proxy-arn> --output json
HTTPS リスナーでは、tls_certificate_sds_secret_configs の name に証明書の ARN を書きます。証明書と秘密鍵は設定ファイルに含めません。config-03-lua-acm.yaml は、config-02 の listeners に次の https_listener を足したものです。
- name: https_listener
address:
socket_address:
address: 0.0.0.0
port_value: 443
filter_chains:
- transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificate_sds_secret_configs:
- name: "arn:aws:acm:ap-northeast-1:123456789012:certificate/<certificate-id>"
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_https
route_config:
name: local_route_https
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match:
prefix: "/"
direct_response:
status: 200
body:
inline_string: "Your proxy is running with an ACM certificate\n"
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
この設定で更新します。
aws elb-proxy update-proxy-configuration \
--proxy-identifier <proxy-arn> \
--cli-binary-format raw-in-base64-out \
--configuration-file configurationBytes@=file://config-03-lua-acm.yaml \
--output json
curl の --connect-to を使うと、DNS を変更せずに、証明書のドメインに一致するホスト名(www.example.com)でプロキシへ接続できます。
$ curl -sv --max-time 15 --connect-to www.example.com:443:<dns-name>:443 https://www.example.com/
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519MLKEM768 / RSASSA-PSS
* Server certificate:
* subject: CN=*.example.com
* issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M01
* subjectAltName: "www.example.com" matches cert's "*.example.com"
* SSL certificate verified via OpenSSL.
< HTTP/1.1 200 OK
< content-length: 46
Your proxy is running with an ACM certificate
反映にかかる時間
更新の受付から反映完了までは、Lua フィルターと HTTPS リスナーのどちらも15〜16秒でした。反映の状況は get-proxy-update で確認できます。--update-identifier には、update-proxy-configuration の応答にある updateId を渡します。
aws elb-proxy get-proxy-update \
--proxy-identifier <proxy-arn> \
--update-identifier <update-id> \
--output json
未対応の Envoy 機能
既存の Envoy 設定を持ち込む場合は、次の項目を確認してください。
- file、stderr、stdout の access logger と admin.access_log_path を使うリソースを含む更新は拒否されます。アクセスログを出すには、open_telemetry、http_grpc、tcp_grpc、fluentd の access logger を使います
- dynamic modules は未対応です
- Wasm のランタイムは V8 だけです
まとめ
ELB for Envoy をリバースプロキシとして動作させ、ACM の証明書で HTTPS 終端できることを確認しました。
自前の Envoy や Nginx を運用していて、維持管理が課題になっている場合は、マネージドサービスとして提供された ELB for Envoy をお試しください。
参考リンク








