Modal logo

OutboundRoute

One rule of an OutboundPolicy: which outbound traffic it matches.

Create routes with the static factories OutboundRoute.tls, OutboundRoute.https, OutboundRoute.ip and OutboundRoute.any. Matched traffic goes to its original destination, except that the any route can block what it matches with block. Routes are immutable: block() returns a new route.

any

static any(): OutboundRoute

Match all traffic that no earlier route matched. Every policy must end with exactly one any route. Without block, the traffic it matches goes to its original destination.

https

static https(params: {
  domains: string[];
  headerReplacements?: OutboundHeaderReplacement[];
}): OutboundRoute

Match HTTPS connections to the given domains on tcp/443. These connections are always decrypted, so the policy must set allowTlsDecryption: true. Requests whose Host header doesn't match the requested domain are refused. Traffic to these domains on other ports or transports isn't matched by this route.

  • params: .domains Domains to match. A *. prefix matches subdomains at any depth but not the domain itself: *.example.com matches a.example.com and a.b.example.com, not example.com. A bare "*" matches all domains.
  • params: .headerReplacements Headers to set on matched requests, in public beta. See OutboundHeaderReplacement. Each header is set on every matching request, so the request has exactly one header with that name and the given value. Copies the request already has are removed, whatever their case, and the header is added if the request has none. A route can set each header name only once, ignoring case.

ip

static ip(params: { cidrs: string[] }): OutboundRoute

Match all traffic to the given CIDRs, on any transport and port.

  • params: .cidrs Destination CIDRs to match, e.g. "203.0.113.0/24".

tls

static tls(params: { domains: string[] }): OutboundRoute

Match connections that carry TLS from the first byte to the given domains, by the domain the client requests (SNI), on tcp/443. These connections are never decrypted. Traffic to these domains on other ports or transports isn't matched by this route.

  • params: .domains Domains to match. A *. prefix matches subdomains at any depth but not the domain itself: *.example.com matches a.example.com and a.b.example.com, not example.com. A bare "*" matches all domains.

block

block(): OutboundRoute

Return a new route that blocks the traffic it matches. Only OutboundRoute.any supports block().