TLS Routing
Transport Layer Security (TLS) routing enables your API Gateway to handle encrypted traffic based on the Server Name Indication (SNI) without needing to terminate the connection. By default, TLS traffic is routed without termination, preserving full end-to-end encryption. However, TLS termination can be enabled if your use case requires it.
Proper TLS routing enables:
🔒 End-to-end encryption by default, with optional termination.
🌐 SNI-based routing to differentiate between secure services.
🏗 Support for multi-tenant architectures using a single IP and port.
🔍 What are the Benefits of TLS Routing?
TLS routing is ideal for environments where secure communication must be preserved from client to backend. With SNI-based routing, the gateway can route requests without accessing the payload, maintaining user privacy and compliance.
A well-configured API Gateway can route TLS traffic using:
- SNI-based rules (e.g., api.example.com → API service, auth.example.com → Auth service).
- TLS passthrough (default): Maintain end-to-end encryption without terminating TLS at the gateway.
- TLS termination (optional): Handle TLS termination at the gateway if you don't want your upstream services to terminate TLS.
TLS Routing Examples
The following examples showcase how you can route TLS traffic to your upstream services.
See the TLS Endpoints page for more details on how ngrok handles TLS endpoints.
- AgentEndpoint
- CloudEndpoint with AgentEndpoint
- Gateway API
Loading…
1. Create an AgentEndpoint
for your upstream Service
Loading…
2. Create a CloudEndpoint
that routes to the AgentEndpoint
Loading…
For TLS and TCP Routes, you must put the domain in the Gateway.Spec.Addresses
field as the ngrok operator needs to know what domains to use when creating endpoints for you and Gateway API forbids using the hostname field
on Gateway listeners for TCP/TLS protocols.
Since the Gateway.Spec.Addresses
are expected to bind to all listeners, you may want to create separate Gateways for TLS and TCP endpoints to prevent unwanted conflicts and overlap.
For these reasons, TCP and TLS routing is often more easily configurable using the AgentEndpoint
resources directly instead of Gateway API configuration.
1. Create a Gateway
If you already have a Gateway
you can use that instead
Loading…
2. Create a TLSRoute
Loading…