TLS termination
Terminate HTTPS at Envoy with local certificates.
TLS in two directions
Envoy can encrypt traffic on either side of itself, and the two are configured independently:
- DownstreamTlsContext — TLS from the client to Envoy. Lives on the listener's filter chain. This is what people usually mean by "TLS termination."
- UpstreamTlsContext — TLS from Envoy to the backend. Lives on the
cluster (
transport_socket). Use this when your backends speak HTTPS or when you're doing mTLS in a service mesh.
You can mix them: HTTPS in front, plain HTTP to backends (very common at the edge), or HTTPS-everywhere with mTLS (typical inside a mesh).
If you find yourself debugging certificate errors, the very first thing to check is whether you put the TLS config in the right place. Downstream = listener. Upstream = cluster. Reversing them is a daily occurrence.
Generate a local cert (the easy way)
The smoothest path on dev machines is mkcert, which installs a local CA trusted by your browser:
# install once
brew install mkcert nss # macOS
# choco install mkcert # Windows
# apt install mkcert # Linux
mkcert -install
mkcert localhost 127.0.0.1
# produces: localhost+1.pem and localhost+1-key.pem
If mkcert isn't an option, plain openssl works too:
openssl req -x509 -newkey rsa:2048 -nodes -keyout server.key -out server.crt \
-subj "/CN=localhost" -days 365
Self-signed: your browser will warn, but curl -k works.
The Envoy config
Take a working hello-world and add a transport_socket to the filter chain.
Move the listener to port 8443 (or 443 if you have privileges).
listeners:
- name: https
address:
socket_address: { address: 0.0.0.0, port_value: 8443 }
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_https
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
route_config:
virtual_hosts:
- name: all
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: backend }
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificates:
- certificate_chain: { filename: "/etc/envoy/certs/server.crt" }
private_key: { filename: "/etc/envoy/certs/server.key" }
Mount the certs alongside the config when you docker run:
docker run --rm -it \
-p 8443:8443 -p 9901:9901 \
-v "$PWD/envoy.yaml:/etc/envoy/envoy.yaml" \
-v "$PWD/server.crt:/etc/envoy/certs/server.crt" \
-v "$PWD/server.key:/etc/envoy/certs/server.key" \
envoyproxy/envoy:v1.31-latest
- Generate a cert with one of the methods above.
- Adapt your hello-world to the listener config above (port 8443, with the
transport_socket). - Run Envoy with the extra cert mounts.
- Test:
curl -kv https://localhost:8443/get
You should see TLS handshake lines and a 200 response. If you used
mkcert, drop the -k — your local CA is trusted.
- Bonus: visit
https://localhost:8443/clustersadmin... no wait, that's port 9901 in plain HTTP. The admin interface stays unencrypted on localhost — this is normal, but reinforces "never expose 9901."
Envoy defaults to TLS 1.2+. To force 1.3 only, set
tls_minimum_protocol_version: TLSv1_3 under
common_tls_context.tls_params. There is no good reason to allow
TLS 1.0 / 1.1 in 2026.
Up next
You've got TLS. Next we'll teach Envoy to not give up the moment a backend hiccups — timeouts, retries, and circuit breakers.
You want Envoy to accept HTTPS from browsers and forward plain HTTP to your app. Which TLS context do you configure?