
I Tried Using Elastic Load Balancing for Envoy (Internal) as a Reverse Proxy Inside a VPC
This page has been translated by machine translation. View original
Introduction
On November 25, 2026, the general availability of Elastic Load Balancing for Envoy (ELB for Envoy) was announced.
I introduced the basic features of ELB for Envoy in a previous article.
This time, assuming Envoy is used as a reverse proxy inside a VPC, I will present the results of routing requests by path from an internal proxy to two internal ALBs that stand in for services.
Test Environment
- Region: Tokyo (ap-northeast-1)
- aws-cli: 2.42.4
- Envoy version (proxyVersion): 1.40
- Subnets: ap-northeast-1a and ap-northeast-1c in the default VPC
- Client EC2: t4g.nano (Amazon Linux 2023)
- Running verification commands: AWS Systems Manager Run Command
- IAM role for the client EC2: AmazonSSMManagedInstanceCore policy attached
Prerequisite Resources
Creating a proxy requires two or more subnets in different AZs of the same VPC, one or more security groups (SGs), and an IAM role for the proxy. The steps to create the role are in the official documentation.
Security Groups
I created three SGs: one for the client, one for the proxy, and one for the ALBs.
| SG | Attached to | Inbound |
|---|---|---|
| Client SG | Client EC2 | None |
| Proxy SG | ELB for Envoy proxy | Allow TCP 80 from the client SG |
| ALB SG | The two internal ALBs | Allow TCP 80 from the proxy SG |
After creating the SGs, I set up allow rules that reference the SGs with the following two commands.
aws ec2 authorize-security-group-ingress --group-id <proxy-sg-id> --protocol tcp --port 80 --source-group <client-sg-id> --output json
aws ec2 authorize-security-group-ingress --group-id <alb-sg-id> --protocol tcp --port 80 --source-group <proxy-sg-id> --output json
Internal ALBs
I created two internal ALBs (service-a and service-b) to stand in for services. Both have the scheme internal and are placed in two subnets, ap-northeast-1a and ap-northeast-1c. For the default action of the HTTP 80 listener, I set a fixed response (status 200, with the body service-a and service-b respectively).
The commands to create the SGs, ALBs, and listeners are as follows.
Commands to create SGs, ALBs, and listeners
SGs (for client, proxy, and ALB)
aws ec2 create-security-group --group-name elbproxy-vpc-client --description "ELB for Envoy VPC routing client" --vpc-id <vpc-id> --query GroupId --output text
aws ec2 create-security-group --group-name elbproxy-vpc-proxy --description "ELB for Envoy VPC routing proxy" --vpc-id <vpc-id> --query GroupId --output text
aws ec2 create-security-group --group-name elbproxy-vpc-alb --description "ELB for Envoy VPC routing alb" --vpc-id <vpc-id> --query GroupId --output text
Internal ALBs (service-a, service-b)
aws elbv2 create-load-balancer --name elbproxy-vpc-service-a --scheme internal --type application --ip-address-type ipv4 --subnets <subnet-a-id> <subnet-c-id> --security-groups <alb-sg-id> --output json
aws elbv2 create-load-balancer --name elbproxy-vpc-service-b --scheme internal --type application --ip-address-type ipv4 --subnets <subnet-a-id> <subnet-c-id> --security-groups <alb-sg-id> --output json
Listeners (HTTP 80, fixed response)
aws elbv2 create-listener --load-balancer-arn <alb-a-arn> --protocol HTTP --port 80 --default-actions "Type=fixed-response,FixedResponseConfig={StatusCode=200,ContentType=text/plain,MessageBody=service-a}" --output json
aws elbv2 create-listener --load-balancer-arn <alb-b-arn> --protocol HTTP --port 80 --default-actions "Type=fixed-response,FixedResponseConfig={StatusCode=200,ContentType=text/plain,MessageBody=service-b}" --output json
Because the ALB DNS names are written in the Envoy configuration, I created the ALBs first and created the proxy after confirming both had become active.
Creating the Proxy
Envoy Configuration File
Save the following content as config-01-path-routing.yaml. Requests whose path starts with /a/ are forwarded to the service_a cluster, and those starting with /b/ are forwarded to the service_b cluster. Requests whose path matches neither receive a direct response with status 404 and the body no route. The clusters use STRICT_DNS, and the forwarding destination is specified as the ALB DNS name with port 80.
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: "/a/"
route:
cluster: service_a
auto_host_rewrite: true
- match:
prefix: "/b/"
route:
cluster: service_b
auto_host_rewrite: true
- match:
prefix: "/"
direct_response:
status: 404
body:
inline_string: "no route\n"
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: service_a
type: STRICT_DNS
dns_lookup_family: V4_ONLY
connect_timeout: 5s
load_assignment:
cluster_name: service_a
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: <alb-a-dns-name>
port_value: 80
- 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: <alb-b-dns-name>
port_value: 80
Proxy Creation Command
The input passed to create-proxy is saved as create-proxy-input.json with the following content.
{
"name": "vpc-routing-proxy",
"type": "envoy",
"proxyVersion": "1.40",
"roleArn": "arn:aws:iam::123456789012:role/aws-elb-proxy-role",
"networkConfiguration": {
"ipConfiguration": {
"ipAddressingConfiguration": {
"ipv4Addressability": "internal",
"ipv6Addressability": "off"
}
},
"vpcConfiguration": {
"subnets": [ { "subnetId": "<subnet-a-id>" }, { "subnetId": "<subnet-c-id>" } ],
"securityGroups": [ { "securityGroupId": "<proxy-sg-id>" } ]
}
}
}
Place the two files in the same directory and run the following command in that directory.
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-path-routing.yaml}' --output json
The dnsName of the created proxy is internal-vpc-routing-proxy-<ID>.elb-proxy.ap-northeast-1.on.aws. The status changed from create-in-progress to active in about 2 minutes.
Verification
When I looked up the proxy's DNS name from the client EC2, it resolved to two private IPs.
$ getent ahostsv4 <proxy-dns-name> | awk '{print $1}' | sort -u
172.31.x.x
172.31.x.x
Next, I sent requests with curl to three paths.
$ curl -sS -m 10 -w '\nHTTP %{http_code}\n' http://<proxy-dns-name>/a/hello
service-a
HTTP 200
$ curl -sS -m 10 -w '\nHTTP %{http_code}\n' http://<proxy-dns-name>/b/hello
service-b
HTTP 200
$ curl -sS -m 10 -w '\nHTTP %{http_code}\n' http://<proxy-dns-name>/c/hello
no route
HTTP 404
service-a and service-b are the fixed response bodies returned by each ALB, and no route is the body that Envoy returned via direct_response.
Summary
I confirmed that ELB for Envoy created as internal can be used as a reverse proxy inside a VPC.
Previously, it was also possible to use resources in a VPC via IP targets of an internal ALB, but the targets required fixed IP addresses. To use a mechanism whose IP addresses change, such as an ALB, you needed to secure fixed IP addresses with something like an NLB. Because ELB for Envoy lets you specify the forwarding destination by DNS name, it may allow more flexible use.
Also, when service endpoints were provided by running Envoy or Nginx in ECS tasks or EKS Pods, replacing them for runtime environment maintenance could become difficult. If this endpoint can be offloaded to ELB for Envoy, it may improve the portability and flexibility of the system.
If you are using Envoy as a hub for publishing services, please try ELB for Envoy, which is now available as a managed service.
