HTTP route

route.VirtualHost

[route.VirtualHost proto]

The top level element in the routing configuration is a virtual host. Each virtual host has a logical name as well as a set of domains that get routed to it based on the incoming request’s host header. This allows a single listener to service multiple top level domain path trees. Once a virtual host is selected based on the domain, the routes are processed in order to see which upstream cluster to route to or whether to perform a redirect.

{
  "name": "...",
  "domains": [],
  "routes": [],
  "require_tls": "...",
  "virtual_clusters": [],
  "rate_limits": [],
  "request_headers_to_add": [],
  "response_headers_to_add": [],
  "response_headers_to_remove": [],
  "cors": "{...}",
  "per_filter_config": "{...}"
}
name
(string, REQUIRED) The logical name of the virtual host. This is used when emitting certain statistics but is not relevant for routing.
domains

(string, REQUIRED) A list of domains (host/authority header) that will be matched to this virtual host. Wildcard hosts are supported in the form of “.foo.com” or “-bar.foo.com”.

Note

The wildcard will not match the empty string. e.g. “-bar.foo.com” will match “baz-bar.foo.com” but not “-bar.foo.com”. Additionally, a special entry “” is allowed which will match any host/authority header. Only a single virtual host in the entire route configuration can match on “*”. A domain must be unique across all virtual hosts or the config will fail to load.

routes
(route.Route) The list of routes that will be matched, in order, for incoming requests. The first route that matches will be used.
require_tls
(route.VirtualHost.TlsRequirementType) Specifies the type of TLS enforcement the virtual host expects. If this option is not specified, there is no TLS requirement for the virtual host.
virtual_clusters
(route.VirtualCluster) A list of virtual clusters defined for this virtual host. Virtual clusters are used for additional statistics gathering.
rate_limits
(route.RateLimit) Specifies a set of rate limit configurations that will be applied to the virtual host.
request_headers_to_add
(core.HeaderValueOption) Specifies a list of HTTP headers that should be added to each request handled by this virtual host. Headers specified at this level are applied after headers from enclosed route.RouteAction and before headers from the enclosing RouteConfiguration. For more information, including details on header value syntax, see the documentation on custom request headers.
response_headers_to_add
(core.HeaderValueOption) Specifies a list of HTTP headers that should be added to each response handled by this virtual host. Headers specified at this level are applied after headers from enclosed route.RouteAction and before headers from the enclosing RouteConfiguration. For more information, including details on header value syntax, see the documentation on custom request headers.
response_headers_to_remove
(string) Specifies a list of HTTP headers that should be removed from each response handled by this virtual host.
cors
(route.CorsPolicy) Indicates that the virtual host has a CORS policy.
per_filter_config
(map<string, Struct>) The per_filter_config field can be used to provide virtual host-specific configurations for filters. The key should match the filter name, such as envoy.buffer for the HTTP buffer filter. Use of this field is filter specific; see the HTTP filter documentation for if and how it is utilized.

Enum route.VirtualHost.TlsRequirementType

[route.VirtualHost.TlsRequirementType proto]

NONE
(DEFAULT) ⁣No TLS requirement for the virtual host.
EXTERNAL_ONLY
⁣External requests must use TLS. If a request is external and it is not using TLS, a 301 redirect will be sent telling the client to use HTTPS.
ALL
⁣All requests must use TLS. If a request is not using TLS, a 301 redirect will be sent telling the client to use HTTPS.

route.Route

[route.Route proto]

A route is both a specification of how to match a request as well as an indication of what to do next (e.g., redirect, forward, rewrite, etc.).

Attention

Envoy supports routing on HTTP method via header matching.

{
  "match": "{...}",
  "route": "{...}",
  "redirect": "{...}",
  "direct_response": "{...}",
  "metadata": "{...}",
  "decorator": "{...}",
  "per_filter_config": "{...}"
}
match
(route.RouteMatch, REQUIRED) Route matching parameters.
route

(route.RouteAction) Route request to some upstream cluster.

Precisely one of route, redirect, direct_response must be set.

redirect

(route.RedirectAction) Return a redirect.

Precisely one of route, redirect, direct_response must be set.

direct_response

(route.DirectResponseAction) Return an arbitrary HTTP response directly, without proxying.

Precisely one of route, redirect, direct_response must be set.

metadata
(core.Metadata) The Metadata field can be used to provide additional information about the route. It can be used for configuration, stats, and logging. The metadata should go under the filter namespace that will need it. For instance, if the metadata is intended for the Router filter, the filter name should be specified as envoy.router.
decorator
(route.Decorator) Decorator for the matched route.
per_filter_config
(map<string, Struct>) The per_filter_config field can be used to provide route-specific configurations for filters. The key should match the filter name, such as envoy.buffer for the HTTP buffer filter. Use of this field is filter specific; see the HTTP filter documentation for if and how it is utilized.

route.WeightedCluster

[route.WeightedCluster proto]

Compared to the cluster field that specifies a single upstream cluster as the target of a request, the weighted_clusters option allows for specification of multiple upstream clusters along with weights that indicate the percentage of traffic to be forwarded to each cluster. The router selects an upstream cluster based on the weights.

{
  "clusters": [],
  "total_weight": "{...}",
  "runtime_key_prefix": "..."
}
clusters
(route.WeightedCluster.ClusterWeight, REQUIRED) Specifies one or more upstream clusters associated with the route.
total_weight
(UInt32Value) Specifies the total weight across all clusters. The sum of all cluster weights must equal this value, which must be greater than 0. Defaults to 100.
runtime_key_prefix
(string) Specifies the runtime key prefix that should be used to construct the runtime keys associated with each cluster. When the runtime_key_prefix is specified, the router will look for weights associated with each upstream cluster under the key runtime_key_prefix + “.” + cluster[i].name where cluster[i] denotes an entry in the clusters array field. If the runtime key for the cluster does not exist, the value specified in the configuration file will be used as the default weight. See the runtime documentation for how key names map to the underlying implementation.

route.WeightedCluster.ClusterWeight

[route.WeightedCluster.ClusterWeight proto]

{
  "name": "...",
  "weight": "{...}",
  "metadata_match": "{...}",
  "request_headers_to_add": [],
  "response_headers_to_add": [],
  "response_headers_to_remove": [],
  "per_filter_config": "{...}"
}
name
(string, REQUIRED) Name of the upstream cluster. The cluster must exist in the cluster manager configuration.
weight
(UInt32Value) An integer between 0 and total_weight. When a request matches the route, the choice of an upstream cluster is determined by its weight. The sum of weights across all entries in the clusters array must add up to the total_weight, which defaults to 100.
metadata_match
(core.Metadata) Optional endpoint metadata match criteria. Only endpoints in the upstream cluster with metadata matching that set in metadata_match will be considered. The filter name should be specified as envoy.lb.
request_headers_to_add
(core.HeaderValueOption) Specifies a list of headers to be added to requests when this cluster is selected through the enclosing route.RouteAction. Headers specified at this level are applied before headers from the enclosing route.RouteAction, route.VirtualHost, and RouteConfiguration. For more information, including details on header value syntax, see the documentation on custom request headers.
response_headers_to_add
(core.HeaderValueOption) Specifies a list of headers to be added to responses when this cluster is selected through the enclosing route.RouteAction. Headers specified at this level are applied before headers from the enclosing route.RouteAction, route.VirtualHost, and RouteConfiguration. For more information, including details on header value syntax, see the documentation on custom request headers.
response_headers_to_remove
(string) Specifies a list of headers to be removed from responses when this cluster is selected through the enclosing route.RouteAction.
per_filter_config
(map<string, Struct>) The per_filter_config field can be used to provide weighted cluster-specific configurations for filters. The key should match the filter name, such as envoy.buffer for the HTTP buffer filter. Use of this field is filter specific; see the HTTP filter documentation for if and how it is utilized.

route.RouteMatch

[route.RouteMatch proto]

{
  "prefix": "...",
  "path": "...",
  "regex": "...",
  "case_sensitive": "{...}",
  "runtime": "{...}",
  "headers": [],
  "query_parameters": []
}
prefix

(string) If specified, the route is a prefix rule meaning that the prefix must match the beginning of the :path header.

Precisely one of prefix, path, regex must be set.

path

(string) If specified, the route is an exact path rule meaning that the path must exactly match the :path header once the query string is removed.

Precisely one of prefix, path, regex must be set.

regex

(string) If specified, the route is a regular expression rule meaning that the regex must match the :path header once the query string is removed. The entire path (without the query string) must match the regex. The rule will not match if only a subsequence of the :path header matches the regex. The regex grammar is defined here.

Examples:

  • The regex /b[io]t matches the path /bit
  • The regex /b[io]t matches the path /bot
  • The regex /b[io]t does not match the path /bite
  • The regex /b[io]t does not match the path /bit/bot

Precisely one of prefix, path, regex must be set.

case_sensitive
(BoolValue) Indicates that prefix/path matching should be case insensitive. The default is true.
runtime
(core.RuntimeUInt32) Indicates that the route should additionally match on a runtime key. An integer between 0-100. Every time the route is considered for a match, a random number between 0-99 is selected. If the number is <= the value found in the key (checked first) or, if the key is not present, the default value, the route is a match (assuming everything also about the route matches). A runtime route configuration can be used to roll out route changes in a gradual manner without full code/config deploys. Refer to the traffic shifting docs for additional documentation.
headers
(route.HeaderMatcher) Specifies a set of headers that the route should match on. The router will check the request’s headers against all the specified headers in the route config. A match will happen if all the headers in the route are present in the request with the same values (or based on presence if the value field is not in the config).
query_parameters
(route.QueryParameterMatcher) Specifies a set of URL query parameters on which the route should match. The router will check the query string from the path header against all the specified query parameters. If the number of specified query parameters is nonzero, they all must match the path header’s query string for a match to occur.

route.CorsPolicy

[route.CorsPolicy proto]

{
  "allow_origin": [],
  "allow_origin_regex": [],
  "allow_methods": "...",
  "allow_headers": "...",
  "expose_headers": "...",
  "max_age": "...",
  "allow_credentials": "{...}",
  "enabled": "{...}"
}
allow_origin

(string) Specifies the origins that will be allowed to do CORS requests.

An origin is allowed if either allow_origin or allow_origin_regex match.

allow_origin_regex

(string) Specifies regex patterns that match allowed origins.

An origin is allowed if either allow_origin or allow_origin_regex match.

allow_methods
(string) Specifies the content for the access-control-allow-methods header.
allow_headers
(string) Specifies the content for the access-control-allow-headers header.
expose_headers
(string) Specifies the content for the access-control-expose-headers header.
max_age
(string) Specifies the content for the access-control-max-age header.
allow_credentials
(BoolValue) Specifies whether the resource allows credentials.
enabled
(BoolValue) Specifies if CORS is enabled. Defaults to true. Only effective on route.

route.RouteAction

[route.RouteAction proto]

{
  "cluster": "...",
  "cluster_header": "...",
  "weighted_clusters": "{...}",
  "cluster_not_found_response_code": "...",
  "metadata_match": "{...}",
  "prefix_rewrite": "...",
  "host_rewrite": "...",
  "auto_host_rewrite": "{...}",
  "timeout": "{...}",
  "idle_timeout": "{...}",
  "retry_policy": "{...}",
  "request_mirror_policy": "{...}",
  "priority": "...",
  "request_headers_to_add": [],
  "response_headers_to_add": [],
  "response_headers_to_remove": [],
  "rate_limits": [],
  "include_vh_rate_limits": "{...}",
  "hash_policy": [],
  "use_websocket": "{...}",
  "websocket_config": "{...}",
  "cors": "{...}",
  "max_grpc_timeout": "{...}"
}
cluster

(string) Indicates the upstream cluster to which the request should be routed to.

Precisely one of cluster, cluster_header, weighted_clusters must be set.

cluster_header

(string) Envoy will determine the cluster to route to by reading the value of the HTTP header named by cluster_header from the request headers. If the header is not found or the referenced cluster does not exist, Envoy will return a 404 response.

Attention

Internally, Envoy always uses the HTTP/2 :authority header to represent the HTTP/1 Host header. Thus, if attempting to match on Host, match on :authority instead.

Precisely one of cluster, cluster_header, weighted_clusters must be set.

weighted_clusters

(route.WeightedCluster) Multiple upstream clusters can be specified for a given route. The request is routed to one of the upstream clusters based on weights assigned to each cluster. See traffic splitting for additional documentation.

Precisely one of cluster, cluster_header, weighted_clusters must be set.

cluster_not_found_response_code
(route.RouteAction.ClusterNotFoundResponseCode) The HTTP status code to use when configured cluster is not found. The default response code is 503 Service Unavailable.
metadata_match
(core.Metadata) Optional endpoint metadata match criteria. Only endpoints in the upstream cluster with metadata matching that set in metadata_match will be considered. The filter name should be specified as envoy.lb.
prefix_rewrite

(string) Indicates that during forwarding, the matched prefix (or path) should be swapped with this value. This option allows application URLs to be rooted at a different path from those exposed at the reverse proxy layer. The router filter will place the original path before rewrite into the x-envoy-original-path header.

Attention

Pay careful attention to the use of trailing slashes in the route’s match prefix value. Stripping a prefix from a path requires multiple Routes to handle all cases. For example, rewriting /prefix to / and /prefix/etc to /etc cannot be done in a single Route, as shown by the below config entries:

- match:
    prefix: "/prefix/"
  route:
    prefix_rewrite: "/"
- match:
    prefix: "/prefix"
  route:
    prefix_rewrite: "/"

Having above entries in the config, requests to /prefix will be stripped to /, while requests to /prefix/etc will be stripped to /etc.

host_rewrite

(string) Indicates that during forwarding, the host header will be swapped with this value.

Only one of host_rewrite, auto_host_rewrite may be set.

auto_host_rewrite

(BoolValue) Indicates that during forwarding, the host header will be swapped with the hostname of the upstream host chosen by the cluster manager. This option is applicable only when the destination cluster for a route is of type strict_dns or logical_dns. Setting this to true with other cluster types has no effect.

Only one of host_rewrite, auto_host_rewrite may be set.

timeout

(Duration) Specifies the upstream timeout for the route. If not specified, the default is 15s. This spans between the point at which the entire downstream request (i.e. end-of-stream) has been processed and when the upstream response has been completely processed.

Note

This timeout includes all retries. See also x-envoy-upstream-rq-timeout-ms, x-envoy-upstream-rq-per-try-timeout-ms, and the retry overview.

idle_timeout

(Duration) Specifies the idle timeout for the route. If not specified, this defaults to 5 minutes. The default value was select so as not to interfere with any smaller configured timeouts that may have existed in configurations prior to the introduction of this feature, while introducing robustness to TCP connections that terminate without FIN. A value of 0 will completely disable the idle timeout.

The idle timeout is distinct to timeout, which provides an upper bound on the upstream response time; idle_timeout instead bounds the amount of time the request’s stream may be idle.

After header decoding, the idle timeout will apply on downstream and upstream request events. Each time an encode/decode event for headers or data is processed for the stream, the timer will be reset. If the timeout fires, the stream is terminated with a 408 Request Timeout error code if no upstream response header has been received, otherwise a stream reset occurs.

retry_policy
(route.RouteAction.RetryPolicy) Indicates that the route has a retry policy.
request_mirror_policy
(route.RouteAction.RequestMirrorPolicy) Indicates that the route has a request mirroring policy.
priority
(core.RoutingPriority) Optionally specifies the routing priority.
request_headers_to_add
(core.HeaderValueOption) Specifies a set of headers that will be added to requests matching this route. Headers specified at this level are applied before headers from the enclosing route.VirtualHost and RouteConfiguration. For more information, including details on header value syntax, see the documentation on custom request headers.
response_headers_to_add
(core.HeaderValueOption) Specifies a set of headers that will be added to responses to requests matching this route. Headers specified at this level are applied before headers from the enclosing route.VirtualHost and RouteConfiguration. For more information, including details on header value syntax, see the documentation on custom request headers.
response_headers_to_remove
(string) Specifies a list of HTTP headers that should be removed from each response to requests matching this route.
rate_limits
(route.RateLimit) Specifies a set of rate limit configurations that could be applied to the route.
include_vh_rate_limits
(BoolValue) Specifies if the rate limit filter should include the virtual host rate limits. By default, if the route configured rate limits, the virtual host rate_limits are not applied to the request.
hash_policy
(route.RouteAction.HashPolicy) Specifies a list of hash policies to use for ring hash load balancing. Each hash policy is evaluated individually and the combined result is used to route the request. The method of combination is deterministic such that identical lists of hash policies will produce the same hash. Since a hash policy examines specific parts of a request, it can fail to produce a hash (i.e. if the hashed header is not present). If (and only if) all configured hash policies fail to generate a hash, no hash will be produced for the route. In this case, the behavior is the same as if no hash policies were specified (i.e. the ring hash load balancer will choose a random backend).
use_websocket

(BoolValue) Indicates that a HTTP/1.1 client connection to this particular route is allowed to upgrade to a WebSocket connection. The default is false.

Attention

If a connection is upgraded to a WebSocket connection, Envoy will set up plain TCP proxying between the client and the upstream server. Hence, an upstream server that rejects the WebSocket upgrade request is also responsible for closing the associated connection. Until then, Envoy will continue to proxy data from the client to the upstream server.

Redirects are not supported on routes where WebSocket upgrades are allowed.

websocket_config
(route.RouteAction.WebSocketProxyConfig) Proxy configuration used for WebSocket connections. If unset, the default values as specified in TcpProxy are used.
cors
(route.CorsPolicy) Indicates that the route has a CORS policy.
max_grpc_timeout
(Duration) If present, and the request is a gRPC request, use the grpc-timeout header, or its default value (infinity) instead of timeout, but limit the applied timeout to the maximum value specified here. If configured as 0, the maximum allowed timeout for gRPC requests is infinity. If not configured at all, the grpc-timeout header is not used and gRPC requests time out like any other requests using timeout or its default. This can be used to prevent unexpected upstream request timeouts due to potentially long time gaps between gRPC request and response in gRPC streaming mode.

route.RouteAction.RetryPolicy

[route.RouteAction.RetryPolicy proto]

HTTP retry architecture overview.

{
  "retry_on": "...",
  "num_retries": "{...}",
  "per_try_timeout": "{...}"
}
retry_on
(string) Specifies the conditions under which retry takes place. These are the same conditions documented for x-envoy-retry-on and x-envoy-retry-grpc-on.
num_retries
(UInt32Value) Specifies the allowed number of retries. This parameter is optional and defaults to 1. These are the same conditions documented for x-envoy-max-retries.
per_try_timeout

(Duration) Specifies a non-zero upstream timeout per retry attempt. This parameter is optional. The same conditions documented for x-envoy-upstream-rq-per-try-timeout-ms apply.

Note

If left unspecified, Envoy will use the global route timeout for the request. Consequently, when using a 5xx based retry policy, a request that times out will not be retried as the total timeout budget would have been exhausted.

route.RouteAction.RequestMirrorPolicy

[route.RouteAction.RequestMirrorPolicy proto]

The router is capable of shadowing traffic from one cluster to another. The current implementation is “fire and forget,” meaning Envoy will not wait for the shadow cluster to respond before returning the response from the primary cluster. All normal statistics are collected for the shadow cluster making this feature useful for testing.

During shadowing, the host/authority header is altered such that -shadow is appended. This is useful for logging. For example, cluster1 becomes cluster1-shadow.

{
  "cluster": "...",
  "runtime_key": "..."
}
cluster
(string, REQUIRED) Specifies the cluster that requests will be mirrored to. The cluster must exist in the cluster manager configuration.
runtime_key
(string) If not specified, all requests to the target cluster will be mirrored. If specified, Envoy will lookup the runtime key to get the % of requests to mirror. Valid values are from 0 to 10000, allowing for increments of 0.01% of requests to be mirrored. If the runtime key is specified in the configuration but not present in runtime, 0 is the default and thus 0% of requests will be mirrored.

route.RouteAction.HashPolicy

[route.RouteAction.HashPolicy proto]

Specifies the route’s hashing policy if the upstream cluster uses a hashing load balancer.

{
  "header": "{...}",
  "cookie": "{...}",
  "connection_properties": "{...}"
}
header

(route.RouteAction.HashPolicy.Header) Header hash policy.

Precisely one of header, cookie, connection_properties must be set.

connection_properties

(route.RouteAction.HashPolicy.ConnectionProperties) Connection properties hash policy.

Precisely one of header, cookie, connection_properties must be set.

route.RouteAction.HashPolicy.Header

[route.RouteAction.HashPolicy.Header proto]

{
  "header_name": "..."
}
header_name
(string, REQUIRED) The name of the request header that will be used to obtain the hash key. If the request header is not present, no hash will be produced.

route.RouteAction.HashPolicy.ConnectionProperties

[route.RouteAction.HashPolicy.ConnectionProperties proto]

{
  "source_ip": "..."
}
source_ip
(bool) Hash on source IP address.

route.RouteAction.WebSocketProxyConfig

[route.RouteAction.WebSocketProxyConfig proto]

{
  "stat_prefix": "...",
  "idle_timeout": "{...}",
  "max_connect_attempts": "{...}"
}
stat_prefix

(string) See stat_prefix. If the parameter is not specified, the default value of “websocket” is used.

WebSocket connections support the downstream statistics for TCP proxy, except for the following, which are reported in the HTTP Connection Manager statistics: - downstream_cx_tx_bytes_total - downstream_cx_tx_bytes_buffered - downstream_cx_rx_bytes_total - downstream_cx_rx_bytes_buffered

idle_timeout
(Duration) See idle_timeout. This timeout is only in effect after the WebSocket upgrade request is received by Envoy. It does not cover the initial part of the HTTP request.
max_connect_attempts
(UInt32Value) See max_connect_attempts.

Enum route.RouteAction.ClusterNotFoundResponseCode

[route.RouteAction.ClusterNotFoundResponseCode proto]

SERVICE_UNAVAILABLE
(DEFAULT) ⁣HTTP status code - 503 Service Unavailable.
NOT_FOUND
⁣HTTP status code - 404 Not Found.

route.RedirectAction

[route.RedirectAction proto]

{
  "host_redirect": "...",
  "path_redirect": "...",
  "prefix_rewrite": "...",
  "response_code": "...",
  "https_redirect": "...",
  "strip_query": "..."
}
host_redirect
(string) The host portion of the URL will be swapped with this value.
path_redirect

(string) The path portion of the URL will be swapped with this value.

Only one of path_redirect, prefix_rewrite may be set.

prefix_rewrite

(string) Indicates that during redirection, the matched prefix (or path) should be swapped with this value. This option allows redirect URLs be dynamically created based on the request.

Attention

Pay attention to the use of trailing slashes as mentioned in RouteAction’s prefix_rewrite.

Only one of path_redirect, prefix_rewrite may be set.

response_code
(route.RedirectAction.RedirectResponseCode) The HTTP status code to use in the redirect response. The default response code is MOVED_PERMANENTLY (301).
https_redirect
(bool) The scheme portion of the URL will be swapped with “https”.
strip_query
(bool) Indicates that during redirection, the query portion of the URL will be removed. Default value is false.

Enum route.RedirectAction.RedirectResponseCode

[route.RedirectAction.RedirectResponseCode proto]

MOVED_PERMANENTLY
(DEFAULT) ⁣Moved Permanently HTTP Status Code - 301.
FOUND
⁣Found HTTP Status Code - 302.
SEE_OTHER
⁣See Other HTTP Status Code - 303.
TEMPORARY_REDIRECT
⁣Temporary Redirect HTTP Status Code - 307.
PERMANENT_REDIRECT
⁣Permanent Redirect HTTP Status Code - 308.

route.DirectResponseAction

[route.DirectResponseAction proto]

{
  "status": "...",
  "body": "{...}"
}
status
(uint32) Specifies the HTTP response status to be returned.
body

(core.DataSource) Specifies the content of the response body. If this setting is omitted, no body is included in the generated response.

Note

Headers can be specified using response_headers_to_add in RouteConfiguration.

route.Decorator

[route.Decorator proto]

{
  "operation": "..."
}
operation

(string, REQUIRED) The operation name associated with the request matched to this route. If tracing is enabled, this information will be used as the span name reported for this request.

Note

For ingress (inbound) requests, or egress (outbound) responses, this value may be overridden by the x-envoy-decorator-operation header.

route.VirtualCluster

[route.VirtualCluster proto]

A virtual cluster is a way of specifying a regex matching rule against certain important endpoints such that statistics are generated explicitly for the matched requests. The reason this is useful is that when doing prefix/path matching Envoy does not always know what the application considers to be an endpoint. Thus, it’s impossible for Envoy to generically emit per endpoint statistics. However, often systems have highly critical endpoints that they wish to get “perfect” statistics on. Virtual cluster statistics are perfect in the sense that they are emitted on the downstream side such that they include network level failures.

Documentation for virtual cluster statistics.

Note

Virtual clusters are a useful tool, but we do not recommend setting up a virtual cluster for every application endpoint. This is both not easily maintainable and as well the matching and statistics output are not free.

{
  "pattern": "...",
  "name": "...",
  "method": "..."
}
pattern

(string, REQUIRED) Specifies a regex pattern to use for matching requests. The entire path of the request must match the regex. The regex grammar used is defined here.

Examples:

  • The regex /rides/d+ matches the path /rides/0
  • The regex /rides/d+ matches the path /rides/123
  • The regex /rides/d+ does not match the path /rides/123/456
name
(string, REQUIRED) Specifies the name of the virtual cluster. The virtual cluster name as well as the virtual host name are used when emitting statistics. The statistics are emitted by the router filter and are documented here.
method
(core.RequestMethod) Optionally specifies the HTTP method to match on. For example GET, PUT, etc.

route.RateLimit

[route.RateLimit proto]

Global rate limiting architecture overview.

{
  "stage": "{...}",
  "disable_key": "...",
  "actions": []
}
stage

(UInt32Value) Refers to the stage set in the filter. The rate limit configuration only applies to filters with the same stage number. The default stage number is 0.

Note

The filter supports a range of 0 - 10 inclusively for stage numbers.

disable_key
(string) The key to be set in runtime to disable this rate limit configuration.
actions
(route.RateLimit.Action, REQUIRED) A list of actions that are to be applied for this rate limit configuration. Order matters as the actions are processed sequentially and the descriptor is composed by appending descriptor entries in that sequence. If an action cannot append a descriptor entry, no descriptor is generated for the configuration. See composing actions for additional documentation.

route.RateLimit.Action

[route.RateLimit.Action proto]

{
  "source_cluster": "{...}",
  "destination_cluster": "{...}",
  "request_headers": "{...}",
  "remote_address": "{...}",
  "generic_key": "{...}",
  "header_value_match": "{...}"
}
source_cluster

(route.RateLimit.Action.SourceCluster) Rate limit on source cluster.

Precisely one of source_cluster, destination_cluster, request_headers, remote_address, generic_key, header_value_match must be set.

destination_cluster

(route.RateLimit.Action.DestinationCluster) Rate limit on destination cluster.

Precisely one of source_cluster, destination_cluster, request_headers, remote_address, generic_key, header_value_match must be set.

request_headers

(route.RateLimit.Action.RequestHeaders) Rate limit on request headers.

Precisely one of source_cluster, destination_cluster, request_headers, remote_address, generic_key, header_value_match must be set.

remote_address

(route.RateLimit.Action.RemoteAddress) Rate limit on remote address.

Precisely one of source_cluster, destination_cluster, request_headers, remote_address, generic_key, header_value_match must be set.

generic_key

(route.RateLimit.Action.GenericKey) Rate limit on a generic key.

Precisely one of source_cluster, destination_cluster, request_headers, remote_address, generic_key, header_value_match must be set.

header_value_match

(route.RateLimit.Action.HeaderValueMatch) Rate limit on the existence of request headers.

Precisely one of source_cluster, destination_cluster, request_headers, remote_address, generic_key, header_value_match must be set.

route.RateLimit.Action.SourceCluster

[route.RateLimit.Action.SourceCluster proto]

The following descriptor entry is appended to the descriptor:

("source_cluster", "<local service cluster>")

<local service cluster> is derived from the --service-cluster option.

{}

route.RateLimit.Action.DestinationCluster

[route.RateLimit.Action.DestinationCluster proto]

The following descriptor entry is appended to the descriptor:

("destination_cluster", "<routed target cluster>")

Once a request matches against a route table rule, a routed cluster is determined by one of the following route table configuration settings:

  • cluster indicates the upstream cluster to route to.
  • weighted_clusters chooses a cluster randomly from a set of clusters with attributed weight.
  • cluster_header indicates which header in the request contains the target cluster.
{}

route.RateLimit.Action.RequestHeaders

[route.RateLimit.Action.RequestHeaders proto]

The following descriptor entry is appended when a header contains a key that matches the header_name:

("<descriptor_key>", "<header_value_queried_from_header>")
{
  "header_name": "...",
  "descriptor_key": "..."
}
header_name
(string, REQUIRED) The header name to be queried from the request headers. The header’s value is used to populate the value of the descriptor entry for the descriptor_key.
descriptor_key
(string, REQUIRED) The key to use in the descriptor entry.

route.RateLimit.Action.RemoteAddress

[route.RateLimit.Action.RemoteAddress proto]

The following descriptor entry is appended to the descriptor and is populated using the trusted address from x-forwarded-for:

("remote_address", "<trusted address from x-forwarded-for>")
{}

route.RateLimit.Action.GenericKey

[route.RateLimit.Action.GenericKey proto]

The following descriptor entry is appended to the descriptor:

("generic_key", "<descriptor_value>")
{
  "descriptor_value": "..."
}
descriptor_value
(string, REQUIRED) The value to use in the descriptor entry.

route.RateLimit.Action.HeaderValueMatch

[route.RateLimit.Action.HeaderValueMatch proto]

The following descriptor entry is appended to the descriptor:

("header_match", "<descriptor_value>")
{
  "descriptor_value": "...",
  "expect_match": "{...}",
  "headers": []
}
descriptor_value
(string, REQUIRED) The value to use in the descriptor entry.
expect_match
(BoolValue) If set to true, the action will append a descriptor entry when the request matches the headers. If set to false, the action will append a descriptor entry when the request does not match the headers. The default value is true.
headers
(route.HeaderMatcher, REQUIRED) Specifies a set of headers that the rate limit action should match on. The action will check the request’s headers against all the specified headers in the config. A match will happen if all the headers in the config are present in the request with the same values (or based on presence if the value field is not in the config).

route.HeaderMatcher

[route.HeaderMatcher proto]

Attention

Internally, Envoy always uses the HTTP/2 :authority header to represent the HTTP/1 Host header. Thus, if attempting to match on Host, match on :authority instead.

Attention

To route on HTTP method, use the special HTTP/2 :method header. This works for both HTTP/1 and HTTP/2 as Envoy normalizes headers. E.g.,

{
  "name": ":method",
  "value": "POST"
}

Attention

In the absence of any header match specifier, match will default to present_match. i.e, a request that has the name header will match, regardless of the header’s value.

{
  "name": "...",
  "exact_match": "...",
  "regex_match": "...",
  "range_match": "{...}",
  "present_match": "...",
  "prefix_match": "...",
  "suffix_match": "...",
  "invert_match": "..."
}
name
(string, REQUIRED) Specifies the name of the header in the request.
exact_match

(string) If specified, header match will be performed based on the value of the header.

Only one of exact_match, regex_match, range_match, present_match, prefix_match, suffix_match may be set.

regex_match

(string) If specified, this regex string is a regular expression rule which implies the entire request header value must match the regex. The rule will not match if only a subsequence of the request header value matches the regex. The regex grammar used in the value field is defined here.

Examples:

  • The regex d{3} matches the value 123
  • The regex d{3} does not match the value 1234
  • The regex d{3} does not match the value 123.456

Only one of exact_match, regex_match, range_match, present_match, prefix_match, suffix_match may be set.

range_match

(type.Int64Range) If specified, header match will be performed based on range. The rule will match if the request header value is within this range. The entire request header value must represent an integer in base 10 notation: consisting of an optional plus or minus sign followed by a sequence of digits. The rule will not match if the header value does not represent an integer. Match will fail for empty values, floating point numbers or if only a subsequence of the header value is an integer.

Examples:

  • For range [-10,0), route will match for header value -1, but not for 0, “somestring”, 10.9, “-1somestring”

Only one of exact_match, regex_match, range_match, present_match, prefix_match, suffix_match may be set.

present_match

(bool) If specified, header match will be be performed based on whether the header is in the request.

Only one of exact_match, regex_match, range_match, present_match, prefix_match, suffix_match may be set.

prefix_match

(string, REQUIRED) If specified, header match will be performed based on the prefix of the header value. Note: empty prefix is not allowed, please use present_match instead.

Examples:

  • The prefix abcd matches the value abcdxyz, but not for abcxyz.

Only one of exact_match, regex_match, range_match, present_match, prefix_match, suffix_match may be set.

suffix_match

(string, REQUIRED) If specified, header match will be performed based on the suffix of the header value. Note: empty suffix is not allowed, please use present_match instead.

Examples:

  • The suffix abcd matches the value xyzabcd, but not for xyzbcd.

Only one of exact_match, regex_match, range_match, present_match, prefix_match, suffix_match may be set.

invert_match

(bool) If specified, the match result will be inverted before checking. Defaults to false.

Examples:

  • The regex d{3} does not match the value 1234, so it will match when inverted.
  • The range [-10,0) will match the value -1, so it will not match when inverted.

route.QueryParameterMatcher

[route.QueryParameterMatcher proto]

Query parameter matching treats the query string of a request’s :path header as an ampersand-separated list of keys and/or key=value elements.

{
  "name": "...",
  "value": "...",
  "regex": "{...}"
}
name
(string, REQUIRED) Specifies the name of a key that must be present in the requested path’s query string.
value
(string) Specifies the value of the key. If the value is absent, a request that contains the key in its query string will match, whether the key appears with a value (e.g., “?debug=true”) or not (e.g., “?debug”)
regex
(BoolValue) Specifies whether the query parameter value is a regular expression. Defaults to false. The entire query parameter value (i.e., the part to the right of the equals sign in “key=value”) must match the regex. E.g., the regex “d+$” will match “123” but not “a123” or “123a”.