2018-10-11 09:44:42 +00:00
---
2020-04-07 18:55:19 +00:00
layout: docs
2022-09-13 20:58:57 +00:00
page_title: Envoy Proxy Configuration | Service Mesh
description: >-
2022-09-16 15:28:32 +00:00
Consul supports Envoy proxies to direct traffic throughout the service mesh. Learn about Consul versions and their Envoy support, and use the reference guide to review options for bootstrap configuration, dynamic configuration, and advanced topics like escape hatch overrides.
2018-10-11 09:44:42 +00:00
---
2022-09-13 20:58:57 +00:00
# Envoy Proxy Configuration for Service Mesh
2018-10-11 09:44:42 +00:00
2023-05-05 17:41:40 +00:00
Consul service mesh has first class support for using
2018-10-11 09:44:42 +00:00
[Envoy](https://www.envoyproxy.io) as a proxy. Consul configures Envoy by
optionally exposing a gRPC service on the local agent that serves [Envoy's xDS
configuration
2021-06-10 15:59:54 +00:00
API](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-docs/xds_protocol).
2018-10-11 09:44:42 +00:00
2021-08-09 18:47:26 +00:00
Consul can configure Envoy sidecars to proxy traffic over the following protocols:
| Protocol | Service network support |
| ----------------------- | ----------------------- |
| HTTP/1.1 | L7 |
| HTTP2 | L7 |
| gRPC | L7 |
| All TCP-based protocols | L4 |
On Consul 1.5.0 and older, Envoy proxies can only proxy TCP traffic at L4.
2023-01-20 17:12:18 +00:00
Some [L7 features](/consul/docs/connect/l7-traffic) can be configured using [configuration entries](/consul/docs/agent/config-entries). You can add [custom Envoy configurations](#advanced-configuration) to the [proxy service definition](/consul/docs/connect/registration/service-registration) to use Envoy features that are not currently exposed through configuration entries. Adding custom Envoy configurations to the service definition is an interim solution that enables you to use the more powerful features of Envoy.
2018-10-11 09:44:42 +00:00
2023-01-20 17:12:18 +00:00
~> **Note:** When using Envoy with Consul and not using the [`consul connect envoy` command](/consul/commands/connect/envoy)
2020-07-31 20:52:49 +00:00
Envoy must be run with the `--max-obj-name-len` option set to `256` or greater for Envoy versions prior to 1.11.0.
2019-07-26 19:43:15 +00:00
2018-10-11 09:44:42 +00:00
## Supported Versions
2022-05-10 14:28:33 +00:00
The following matrix describes Envoy compatibility for the currently supported **n-2 major Consul releases**. For previous Consul version compatibility please view the respective versioned docs for this page.
2021-08-09 18:47:26 +00:00
2022-10-04 20:02:28 +00:00
### Envoy and Consul Client Agent
2022-03-03 18:34:30 +00:00
Consul supports **four major Envoy releases** at the beginning of each major Consul release. Consul maintains compatibility with Envoy patch releases for each major version so that users can benefit from bug and security fixes in Envoy. As a policy, Consul will add support for a new major versions of Envoy in a Consul major release. Support for newer versions of Envoy will not be added to existing releases.
| Consul Version | Compatible Envoy Versions |
| ------------------- | -----------------------------------------------------------------------------------|
2023-04-12 21:43:15 +00:00
| 1.15.x | 1.25.4, 1.24.6, 1.23.8, 1.22.11 |
2022-10-31 15:50:45 +00:00
| 1.14.x | 1.24.0, 1.23.1, 1.22.5, 1.21.5 |
2022-10-04 20:15:01 +00:00
| 1.13.x | 1.23.1, 1.22.5, 1.21.5, 1.20.7 |
2018-10-11 09:44:42 +00:00
2022-10-04 20:02:28 +00:00
### Envoy and Consul Dataplane
2023-04-12 21:43:15 +00:00
The Consul dataplane component was introduced in Consul v1.14 as a way to manage Envoy proxies without the use of Consul clients. Each new minor version of Consul is released with a new minor version of Consul dataplane, which packages both Envoy and the `consul-dataplane` binary in a single container image. For backwards compatability reasons, each new minor version of Consul will also support the previous minor version of Consul dataplane to allow for seamless upgrades. In addition, each minor version of Consul will support the next minor version of Consul dataplane to allow for extended dataplane support via newer versions of Envoy.
2022-10-04 20:02:28 +00:00
2023-02-28 00:50:01 +00:00
| Consul Version | Consul Dataplane Version (Bundled Envoy Version) |
| ------------------- | ------------------------------------------------- |
| 1.15.x | 1.1.x (Envoy 1.25.x), 1.0.x (Envoy 1.24.x) |
2023-02-28 18:38:29 +00:00
| 1.14.x | 1.1.x (Envoy 1.25.x), 1.0.x (Envoy 1.24.x) |
2022-10-04 20:02:28 +00:00
2018-10-11 09:44:42 +00:00
## Getting Started
To get started with Envoy and see a working example you can follow the [Using
2023-05-05 17:41:40 +00:00
Envoy with Consul service mesh](/consul/tutorials/developer-mesh/service-mesh-with-envoy-proxy?utm_source=docs) tutorial.
2018-10-11 09:44:42 +00:00
2019-05-08 21:03:53 +00:00
## Configuration
2018-10-11 09:44:42 +00:00
2019-05-08 21:03:53 +00:00
Envoy proxies require two types of configuration: an initial _bootstrap
2021-08-09 18:47:26 +00:00
configuration_ and a _dynamic configuration_ that is discovered from a "management
2019-05-08 21:03:53 +00:00
server", in this case Consul.
2018-10-11 09:44:42 +00:00
2019-05-08 21:03:53 +00:00
The bootstrap configuration at a minimum needs to configure the proxy with an
2020-10-14 15:23:05 +00:00
identity (node id) and the location of its local Consul agent from which it
discovers all of its dynamic configuration. See [Bootstrap
2019-05-08 21:03:53 +00:00
Configuration](#bootstrap-configuration) for more details.
2018-10-11 09:44:42 +00:00
2023-05-05 17:41:40 +00:00
The dynamic configuration Consul service mesh provides to each Envoy instance includes:
2019-05-08 21:03:53 +00:00
2020-04-06 20:27:35 +00:00
- TLS certificates and keys to enable mutual authentication and keep certificates
rotating.
2020-10-14 15:23:05 +00:00
- [Intentions] to enforce service-to-service authorization rules.
2020-04-06 20:27:35 +00:00
- Service-discovery results for upstreams to enable each sidecar proxy to load-balance
outgoing connections.
- L7 configuration including timeouts and protocol-specific options.
2023-01-20 17:12:18 +00:00
- Configuration to [expose specific HTTP paths](/consul/docs/connect/registration/service-registration#expose-paths-configuration-reference).
2019-05-08 21:03:53 +00:00
For more information on the parts of the Envoy proxy runtime configuration
2023-05-05 17:41:40 +00:00
that are currently controllable via Consul service mesh, refer to [Dynamic
2019-05-08 21:03:53 +00:00
Configuration](#dynamic-configuration).
2018-10-11 09:44:42 +00:00
2019-05-08 21:03:53 +00:00
We plan to enable more and more of Envoy's features through
2023-05-05 17:41:40 +00:00
Consul service mesh's first-class configuration over time, however some advanced users will
2019-05-08 21:03:53 +00:00
need additional control to configure Envoy in specific ways. To enable this, we
provide several ["escape hatch"](#advanced-configuration) options that allow
users to provide low-level raw Envoy config syntax for some sub-components in each
Envoy instance. This allows operators to have full control over and
responsibility for correctly configuring Envoy and ensuring version support etc.
2020-10-14 15:23:05 +00:00
## Intention Enforcement
2023-01-20 17:12:18 +00:00
[Intentions](/consul/docs/connect/intentions) are enforced using Envoy's RBAC filters. Depending on the
configured [protocol](/consul/docs/connect/config-entries/service-defaults#protocol) of the proxied service, intentions are either enforced
2021-08-09 18:47:26 +00:00
per-connection (L4) using a network filter, or per-request (L7) using an HTTP
2020-10-14 15:23:05 +00:00
filter.
-> **Note:** Prior to Consul 1.9.0 intentions were exclusively enforced
per-connection (L4) using an `ext_authz` network filter.
2021-08-09 18:47:26 +00:00
## Fetching Certificates
2023-01-20 17:12:18 +00:00
Envoy will use the [`CONSUL_HTTP_TOKEN`](/consul/commands#consul_http_token) and [`CONSUL_HTTP_ADDR`](/consul/commands#consul_http_addr) environment variables to contact Consul to fetch certificates if the following conditions are met:
2021-08-09 18:47:26 +00:00
2021-08-09 20:36:07 +00:00
- The `CONSUL_HTTP_TOKEN` environment variable contains a Consul ACL token.
- The Consul ACL token has the necessary permissions to read configuration for that service.
2021-08-09 18:47:26 +00:00
If TLS is enabled on Consul, you will also need to add the following environment variables _prior_ to starting Envoy:
2023-01-20 17:12:18 +00:00
- [`CONSUL_CACERT`](/consul/commands#consul_cacert)
- [`CONSUL_CLIENT_CERT`](/consul/commands#consul_client_cert)
2023-03-24 19:35:34 +00:00
- [`CONSUL_CLIENT_KEY`](/consul/commands#consul_client_key)
2023-01-20 17:12:18 +00:00
- [`CONSUL_HTTP_SSL`](/consul/commands#consul_http_ssl)
2021-08-09 18:47:26 +00:00
2019-05-08 21:03:53 +00:00
## Bootstrap Configuration
2022-11-03 17:05:29 +00:00
Envoy requires an initial bootstrap configuration file. You can either create the file manually using the Consul command line or configure Consul Dataplane to generate the file.
### Generate the bootstrap file on the Consul CLI
2023-01-20 17:12:18 +00:00
Connect to a local Consul client agent and run the [`consul connect envoy` command](/consul/commands/connect/envoy) to create the Envoy bootstrap configuration. The command either outputs the bootstrap configuration directly to stdout or generates the configuration and issues an `exec` command to the Envoy binary as a convenience wrapper. For more information about using `exec` to bootstrap Envoy, refer to [Exec Security Details](/consul/commands/connect/envoy#exec-security-details).
2022-11-03 17:05:29 +00:00
2023-01-31 21:30:20 +00:00
If you experience issues when bootstrapping Envoy proxies from the CLI, use the
`-enable-config-gen-logging` flag to enable debug message logging. These logs can
2023-04-12 21:43:15 +00:00
help you troubleshoot issues that occur during the bootstrapping process.
2023-01-31 21:30:20 +00:00
For more information about available flags and parameters, refer to the
[`consul connect envoy CLI` reference](/consul/commands/connect/envoy).
2022-11-03 17:05:29 +00:00
### Generate the bootstrap file from Consul Dataplane
2023-01-20 17:12:18 +00:00
Consul Dataplane automatically configures and manages an Envoy process. Consul Dataplane generates the Envoy bootstrap configuration file prior to starting Envoy. To configure how Consul Dataplane starts Envoy, refer to the [Consul Dataplane CLI reference](/consul/docs/connect/dataplane/consul-dataplane).
2022-11-03 17:05:29 +00:00
### Control bootstrap configuration from proxy configuration
Consul service mesh can control some parts of the bootstrap configuration by specifying Envoy proxy configuration options.
Add the following configuration items to the [global `proxy-defaults` configuration
2023-01-20 17:12:18 +00:00
entry](/consul/docs/connect/config-entries/proxy-defaults) or override them directly in the `proxy.config`
field of a [proxy service definition](/consul/docs/connect/registration/service-registration). When
2022-11-03 17:05:29 +00:00
connected to a Consul client agent, you can place the configuration in the `proxy.config` field of
2023-01-20 17:12:18 +00:00
the [`sidecar_service`](/consul/docs/connect/registration/sidecar-service) block.
2019-05-08 21:03:53 +00:00
- `envoy_statsd_url` - A URL in the form `udp://ip:port` identifying a UDP
StatsD listener that Envoy should deliver metrics to. For example, this may be
`udp://127.0.0.1:8125` if every host has a local StatsD listener. In this case
users can configure this property once in the [global `proxy-defaults`
2023-01-20 17:12:18 +00:00
configuration entry](/consul/docs/connect/config-entries/proxy-defaults) for convenience. Currently, TCP is not supported.
2019-05-08 21:03:53 +00:00
2020-04-09 00:09:01 +00:00
~> **Note:** currently the url **must use an ip address** not a dns name due
to the way Envoy is setup for StatsD.
2020-04-06 20:27:35 +00:00
2020-08-25 22:19:42 +00:00
Expansion of the environment variable `HOST_IP` is supported, e.g.
`udp://${HOST_IP}:8125`.
2020-04-09 00:09:01 +00:00
Users can also specify the whole parameter in the form `$ENV_VAR_NAME`, which
will cause the `consul connect envoy` command to resolve the actual URL from
the named environment variable when it runs. This, for example, allows each
pod in a Kubernetes cluster to learn of a pod-specific IP address for StatsD
when the Envoy instance is bootstrapped while still allowing global
configuration of all proxies to use StatsD in the [global `proxy-defaults`
2023-01-20 17:12:18 +00:00
configuration entry](/consul/docs/connect/config-entries/proxy-defaults). The env
2020-08-25 22:19:42 +00:00
variable must contain a full valid URL value as specified above and nothing else.
2019-05-08 21:03:53 +00:00
- `envoy_dogstatsd_url` - The same as `envoy_statsd_url` with the following
differences in behavior:
2020-04-06 20:27:35 +00:00
- Envoy will use dogstatsd tags instead of statsd dot-separated metric names.
- As well as `udp://`, a `unix://` URL may be specified if your agent can
listen on a unix socket (e.g. the dogstatsd agent).
2019-05-08 21:03:53 +00:00
- `envoy_prometheus_bind_addr` - Specifies that the proxy should expose a Prometheus
metrics endpoint to the _public_ network. It must be supplied in the form
`ip:port` and port and the ip/port combination must be free within the network
namespace the proxy runs. Typically the IP would be `0.0.0.0` to bind to all
available interfaces or a pod IP address.
2020-04-06 20:27:35 +00:00
-> **Note:** Envoy versions prior to 1.10 do not export timing histograms
using the internal Prometheus endpoint.
2019-05-08 21:03:53 +00:00
2020-02-03 17:19:34 +00:00
- `envoy_stats_bind_addr` - Specifies that the proxy should expose the /stats prefix
to the _public_ network. It must be supplied in the form `ip:port` and
the ip/port combination must be free within the network namespace the proxy runs.
Typically the IP would be `0.0.0.0` to bind to all available interfaces or a pod IP address.
2019-05-08 21:03:53 +00:00
- `envoy_stats_tags` - Specifies one or more static tags that will be added to
all metrics produced by the proxy.
- `envoy_stats_flush_interval` - Configures Envoy's
2021-06-10 15:59:54 +00:00
[`stats_flush_interval`](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-bootstrap-stats-flush-interval).
2019-05-08 21:03:53 +00:00
2023-05-16 18:36:05 +00:00
- `envoy_telemetry_collector_bind_socket_dir` - Specifies the directory where Envoy creates a Unix socket.
Envoy sends metrics to the socket where a Consul telemetry collector can collect them.
The socket is not configured by default.
2021-08-09 18:47:26 +00:00
The [Advanced Configuration](#advanced-configuration) section describes additional configurations that allow incremental or complete control over the bootstrap configuration generated.
2019-05-08 21:03:53 +00:00
2022-09-30 14:52:53 +00:00
### Bootstrap Envoy on Windows VMs
2022-09-27 20:16:39 +00:00
2023-03-24 19:35:34 +00:00
> Complete the [Connect Services on Windows Workloads to Consul Service Mesh tutorial](/consul/tutorials/developer-mesh/consul-windows-workloads) to learn how to deploy Consul and use its service mesh on Windows VMs.
2022-10-03 18:54:08 +00:00
2022-09-27 20:42:05 +00:00
If you are running Consul on a Windows VM, attempting to bootstrap Envoy with the `consul connect envoy` command returns the following output:
2022-09-27 20:16:39 +00:00
```shell-session hideClipboard
Directly running Envoy is only supported on linux and macOS since envoy itself doesn't build on other plataforms currently.
Use the -bootstrap option to generate the JSON to use when running envoy on a supported OS or via a container or VM.
```
To bootstrap Envoy on Windows VMs, you must generate the bootstrap configuration as a .json file and then manually edit it to add both your ACL token and a valid access log path.
2022-09-30 14:58:03 +00:00
To generate the bootstrap configuration file, add the `-bootstrap` option to the command and then save the output to a file:
2022-09-27 20:16:39 +00:00
```shell-session
$ consul connect envoy -bootstrap > bootstrap.json
```
2022-09-30 14:52:53 +00:00
Then, open `bootstrap.json` and update the following sections with your ACL token and log path.
2022-09-30 14:59:21 +00:00
2022-09-30 14:51:58 +00:00
<CodeBlockConfig filename="bootstrap.json" hideClipboard lineNumbers highlight="2,19">
```json
"admin": {
"access_log_path": "/dev/null",
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": 19000
}
}
},
## ...
"dynamic_resources": {
## ...
"ads_config": {
## ...
"grpc_services": {
"initial_metadata": [
{
"key": "x-consul-token",
"value": "<ACL-Token>"
}
],
## ...
}
}
}
}
2022-09-30 15:01:43 +00:00
```
</CodeBlockConfig>
To complete the bootstrap process, start Envoy and include the path to `bootstrap.json`:
2022-09-27 20:16:39 +00:00
```shell-session
2022-09-30 14:52:53 +00:00
$ envoy -c bootstrap.json
2022-09-27 20:16:39 +00:00
```
2022-09-27 20:42:05 +00:00
~> **Security Note**: The bootstrap JSON contains the ACL token and should be handled as a secret. Because this token authorizes the identity of any service it has `service:write` permissions for, it can be used to access upstream services.
2022-09-27 20:16:39 +00:00
2019-05-08 21:03:53 +00:00
## Dynamic Configuration
Consul automatically generates Envoy's dynamic configuration based on its
knowledge of the cluster. Users may specify default configuration options for
2022-11-29 01:33:54 +00:00
a service through the available fields in the [`service-defaults` configuration
2023-01-20 17:12:18 +00:00
entry](/consul/docs/connect/config-entries/service-defaults). Consul will use this
2022-11-29 01:33:54 +00:00
information to configure appropriate proxy settings for that service's proxies
and also for the upstream listeners used by the service.
2019-05-08 21:03:53 +00:00
2022-11-29 01:33:54 +00:00
One example is how users can define a service's protocol in the `Protocol` field of [`service-defaults` configuration
2023-01-20 17:12:18 +00:00
entry](/consul/docs/connect/config-entries/service-defaults). Agents with
[`enable_central_service_config`](/consul/docs/agent/config/config-files#enable_central_service_config)
2019-05-08 21:03:53 +00:00
set to true will automatically discover the protocol when configuring a proxy
for a service. The proxy will discover the main protocol of the service it
represents and use this to configure its main public listener. It will also
discover the protocols defined for any of its upstream services and
automatically configure its upstream listeners appropriately too as below.
This automated discovery results in Consul auto-populating the `proxy.config`
and `proxy.upstreams[*].config` fields of the [proxy service
2023-01-20 17:12:18 +00:00
definition](/consul/docs/connect/registration/service-registration) that is
2019-05-08 21:03:53 +00:00
actually registered.
2020-02-03 17:19:34 +00:00
To learn about other options that can be configured centrally see the
2023-01-20 17:12:18 +00:00
[Configuration Entries](/consul/docs/agent/config-entries) docs.
2019-09-26 02:55:52 +00:00
2019-05-08 21:03:53 +00:00
### Proxy Config Options
2022-11-29 01:33:54 +00:00
These fields may also be overridden explicitly in `proxy.config` of the [proxy service
2023-01-20 17:12:18 +00:00
definition](/consul/docs/connect/registration/service-registration), or defined in
2020-04-06 20:27:35 +00:00
the [global `proxy-defaults` configuration
2023-01-20 17:12:18 +00:00
entry](/consul/docs/connect/config-entries/proxy-defaults) to act as
2019-05-08 21:03:53 +00:00
defaults that are inherited by all services.
2023-05-05 17:41:40 +00:00
- `protocol` - The protocol the service speaks. Consul service mesh's Envoy integration
2019-05-08 21:03:53 +00:00
currently supports the following `protocol` values:
2019-08-21 20:10:12 +00:00
2019-05-08 21:03:53 +00:00
- `tcp` - Unless otherwise specified this is the default, which causes Envoy
2023-05-05 17:41:40 +00:00
to proxy at L4. This provides all the security benefits of the service mesh's mTLS
2019-05-08 21:03:53 +00:00
and works for any TCP-based protocol. Load-balancing and metrics are
available at the connection level.
- `http` - This specifies that the service speaks HTTP/1.x. Envoy will setup an
`http_connection_manager` and will be able to load-balance requests
individually to available upstream services. Envoy will also emit L7 metrics
such as request rates broken down by HTTP response code family (2xx, 4xx, 5xx,
etc).
- `http2` - This specifies that the service speaks http2 (specifically h2c since
Envoy will still only connect to the local service instance via plain TCP not
TLS). This behaves much like `http` with L7 load-balancing and metrics but has
additional settings that correctly enable end-to-end http2.
- `grpc` - gRPC is a common RPC protocol based on http2. In addition to the
http2 support above, Envoy listeners will be configured with a
[gRPC bridge
2021-06-10 15:59:54 +00:00
filter](https://www.envoyproxy.io/docs/envoy/v1.17.2/configuration/http/http_filters/grpc_http1_bridge_filter)
2019-05-08 21:03:53 +00:00
that translates HTTP/1.1 calls into gRPC, and instruments
metrics with `gRPC-status` trailer codes.
2019-08-21 20:10:12 +00:00
~> **Note:** The protocol of a service should ideally be configured via the
2023-01-20 17:12:18 +00:00
[`protocol`](/consul/docs/connect/config-entries/service-defaults#protocol)
2019-08-21 20:10:12 +00:00
field of a
2023-01-20 17:12:18 +00:00
[`service-defaults`](/consul/docs/connect/config-entries/service-defaults)
2019-08-21 20:10:12 +00:00
config entry for the service. Configuring it in a
proxy config will not fully enable some [L7
2023-01-20 17:12:18 +00:00
features](/consul/docs/connect/l7-traffic).
2019-08-21 20:10:12 +00:00
It is supported here for backwards compatibility with Consul versions prior to 1.6.0.
2019-07-05 15:06:47 +00:00
- `bind_address` - Override the address Envoy's public listener binds to. By
default Envoy will bind to the service address or 0.0.0.0 if there is not explicit address on the service registration.
2019-08-21 20:10:12 +00:00
2019-07-05 15:06:47 +00:00
- `bind_port` - Override the port Envoy's public listener binds to. By default
Envoy will bind to the service port.
2019-08-21 20:10:12 +00:00
2019-05-08 21:03:53 +00:00
- `local_connect_timeout_ms` - The number of milliseconds allowed to make
connections to the local application instance before timing out. Defaults to 5000
(5 seconds).
2021-01-25 19:50:00 +00:00
- `local_request_timeout_ms` - In milliseconds, the request timeout for HTTP requests
to the local application instance. Applies to HTTP based protocols only. If not
specified, inherits the Envoy default for route timeouts (15s). A value of 0 will
disable request timeouts.
2022-11-29 22:43:15 +00:00
- `local_idle_timeout_ms` - In milliseconds, the idle timeout for HTTP requests
to the local application instance. Applies to HTTP based protocols only. If not
2023-04-12 21:43:15 +00:00
specified, inherits the Envoy default for route idle timeouts (15s). A value of 0
2022-11-29 22:43:15 +00:00
disables request timeouts.
2022-11-29 01:33:54 +00:00
- `max_inbound_connections` - The maximum number of concurrent inbound connections
to the local application instance. If not specified, inherits the Envoy default (1024).
2022-09-26 16:29:06 +00:00
- `balance_inbound_connections` - The strategy used for balancing inbound connections
across Envoy worker threads. Consul service mesh Envoy integration supports the
following `balance_inbound_connections` values:
2022-11-03 17:05:29 +00:00
- `""` - Empty string (default). No connection balancing strategy is used. Consul does not balance inbound connections.
2022-09-26 16:29:06 +00:00
- `exact_balance` - Inbound connections to the service use the
[Envoy Exact Balance Strategy.](https://cloudnative.to/envoy/api-v3/config/listener/v3/listener.proto.html#config-listener-v3-listener-connectionbalanceconfig-exactbalance)
2019-05-08 21:03:53 +00:00
### Proxy Upstream Config Options
The following configuration items may be overridden directly in the
`proxy.upstreams[].config` field of a [proxy service
2023-01-20 17:12:18 +00:00
definition](/consul/docs/connect/registration/service-registration) or
[`sidecar_service`](/consul/docs/connect/registration/sidecar-service) block.
2019-05-08 21:03:53 +00:00
- `protocol` - Same as above in main config but affects the listener setup for
the upstream.
2019-08-21 20:10:12 +00:00
2020-04-06 20:27:35 +00:00
~> **Note:** The protocol of a service should ideally be configured via the
2023-01-20 17:12:18 +00:00
[`protocol`](/consul/docs/connect/config-entries/service-defaults#protocol)
2020-04-06 20:27:35 +00:00
field of a
2023-01-20 17:12:18 +00:00
[`service-defaults`](/consul/docs/connect/config-entries/service-defaults)
2020-04-06 20:27:35 +00:00
config entry for the upstream destination service. Configuring it in a
proxy upstream config will not fully enable some [L7
2023-01-20 17:12:18 +00:00
features](/consul/docs/connect/l7-traffic).
2020-04-06 20:27:35 +00:00
It is supported here for backwards compatibility with Consul versions prior to 1.6.0.
2019-08-21 20:10:12 +00:00
2019-05-08 21:03:53 +00:00
- `connect_timeout_ms` - The number of milliseconds to allow when making upstream
connections before timing out. Defaults to 5000
(5 seconds).
2020-04-06 20:27:35 +00:00
~> **Note:** The connection timeout for a service should ideally be
configured via the
2023-01-20 17:12:18 +00:00
[`connect_timeout`](/consul/docs/connect/config-entries/service-resolver#connecttimeout)
2020-04-06 20:27:35 +00:00
field of a
2023-01-20 17:12:18 +00:00
[`service-resolver`](/consul/docs/connect/config-entries/service-resolver)
2020-04-06 20:27:35 +00:00
config entry for the upstream destination service. Configuring it in a
proxy upstream config will override any values defined in config entries.
It is supported here for backwards compatibility with Consul versions prior to 1.6.0.
2019-08-21 20:10:12 +00:00
2019-12-03 20:13:33 +00:00
- `limits` - A set of limits to apply when connecting to the upstream service.
2020-04-06 20:27:35 +00:00
These limits are applied on a per-service-instance basis. The following
2019-12-03 20:13:33 +00:00
limits are respected:
- `max_connections` - The maximum number of connections a service instance
will be allowed to establish against the given upstream. Use this to limit
HTTP/1.1 traffic, since HTTP/1.1 has a request per connection.
- `max_pending_requests` - The maximum number of requests that will be queued
while waiting for a connection to be established. For this configuration to
be respected, a L7 protocol must be defined in the `protocol` field.
- `max_concurrent_requests` - The maximum number of concurrent requests that
will be allowed at a single point in time. Use this to limit HTTP/2 traffic,
since HTTP/2 has many requests per connection. For this configuration to be
respected, a L7 protocol must be defined in the `protocol` field.
2022-12-13 16:51:37 +00:00
- `passive_health_check` - Passive health checks remove hosts from the upstream
cluster that are unreachable or that return errors.
- `interval` - The time in nanosecond between checks. Each check will cause
hosts which have exceeded `max_failures` to be removed from the load
balancer, and any hosts which have passed their ejection time to be
returned to the load balancer. If not specified, it uses the default value.
For example, 10s for Envoy proxy.
- `max_failures` - The number of consecutive failures that cause a host to be
removed from the upstream cluster. If not specified, Consul uses the proxy's
default value. For example, `5` for Envoy proxy.
- `enforcing_consecutive_5xx` - A percentage representing the chance that a
host will be actually ejected when the proxy detects an outlier status
through consecutive errors in the 500 code range. If not specified, Consul
uses the proxy's default value. For example, `100` for Envoy proxy.
2023-04-26 22:59:48 +00:00
- `max_ejection_percent` - The maximum percentage of hosts that can be ejected
from a upstream cluster due to passive health check failures. If not specified,
inherits Envoy's default of 10% or at least one host.
- `base_ejection_time` - The base time that a host is ejected for. The real
time is equal to the base time multiplied by the number of times the host has
been ejected and is capped by max_ejection_time (Default 300s). If not
speficied, inherits Envoy's default value of 30s.
2020-04-27 18:53:21 +00:00
2022-09-26 16:29:06 +00:00
- `balance_outbound_connections` - Specifies the strategy for balancing outbound connections
across Envoy worker threads. Consul service mesh Envoy integration supports the
following `balance_outbound_connections` values:
2022-11-03 17:05:29 +00:00
- `""` - Empty string (default). No connection balancing strategy is used. Consul does not balance outbound connections.
2022-09-26 16:29:06 +00:00
- `exact_balance` - Outbound connections from the upstream use the
[Envoy Exact Balance Strategy.](https://cloudnative.to/envoy/api-v3/config/listener/v3/listener.proto.html#config-listener-v3-listener-connectionbalanceconfig-exactbalance)
2020-03-26 16:20:56 +00:00
### Gateway Options
2019-07-08 23:40:57 +00:00
These fields may also be overridden explicitly in the [proxy service
2023-01-20 17:12:18 +00:00
definition](/consul/docs/connect/registration/service-registration), or defined in
2020-04-06 20:27:35 +00:00
the [global `proxy-defaults` configuration
2023-01-20 17:12:18 +00:00
entry](/consul/docs/connect/config-entries/proxy-defaults) to act as
2019-07-08 23:40:57 +00:00
defaults that are inherited by all services.
2020-04-06 20:27:35 +00:00
Prior to 1.8.0 these settings were specific to Mesh Gateways. The deprecated
2020-03-26 16:20:56 +00:00
names such as `envoy_mesh_gateway_bind_addresses` and `envoy_mesh_gateway_no_default_bind`
will continue to be supported.
2019-07-08 23:40:57 +00:00
- `connect_timeout_ms` - The number of milliseconds to allow when making upstream
2020-03-17 19:50:14 +00:00
connections before timing out. Defaults to 5000 (5 seconds). If the upstream
service has the configuration option
2023-01-20 17:12:18 +00:00
[`connect_timeout_ms`](/consul/docs/connect/config-entries/service-resolver#connecttimeout)
2020-03-17 19:50:14 +00:00
set for the `service-resolver`, that timeout value will take precedence over
2020-03-26 16:20:56 +00:00
this gateway option.
2019-07-08 23:40:57 +00:00
2020-03-26 16:20:56 +00:00
- `envoy_gateway_bind_tagged_addresses` - Indicates that the gateway
2019-07-08 23:40:57 +00:00
services tagged addresses should be bound to listeners in addition to the
2020-04-06 20:27:35 +00:00
default listener address.
2019-07-08 23:40:57 +00:00
2020-03-26 16:20:56 +00:00
- `envoy_gateway_bind_addresses` - A map of additional addresses to be bound.
2019-07-08 23:40:57 +00:00
This map's keys are the name of the listeners to be created and the values are
a map with two keys, address and port, that combined make the address to bind the
listener to. These are bound in addition to the default address.
2020-03-26 16:20:56 +00:00
- `envoy_gateway_no_default_bind` - Prevents binding to the default address
of the gateway service. This should be used with one of the other options
to configure the gateway's bind addresses.
2020-07-08 23:09:00 +00:00
2020-06-03 21:28:45 +00:00
- `envoy_dns_discovery_type` - Determines how Envoy will resolve hostnames. Defaults to `LOGICAL_DNS`.
Must be one of `STRICT_DNS` or `LOGICAL_DNS`. Details for each type are available in
2021-06-10 15:59:54 +00:00
the [Envoy documentation](https://www.envoyproxy.io/docs/envoy/v1.17.2/intro/arch_overview/upstream/service_discovery).
2020-06-03 21:28:45 +00:00
This option applies to terminating gateways that route to services
2021-06-16 20:13:32 +00:00
addressed by a hostname, such as a managed database. It also applies to mesh gateways,
2020-06-03 21:28:45 +00:00
such as when gateways in other Consul datacenters are behind a load balancer that is addressed by a hostname.
2019-07-08 23:40:57 +00:00
2022-10-11 19:22:55 +00:00
- `envoy_gateway_remote_tcp_enable_keepalive` - Enables TCP keepalive settings on remote
upstream connections for mesh and terminating gateways. Defaults to `false`. Must be one
of `true` or `false`. Details for this feature are available in the
[Envoy documentation](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/address.proto#envoy-v3-api-msg-config-core-v3-tcpkeepalive).
2022-10-06 17:22:07 +00:00
2022-10-11 19:22:55 +00:00
- `envoy_gateway_remote_tcp_keepalive_time` - The number of seconds a connection needs to
2022-10-06 17:22:07 +00:00
be idle before keep-alive probes start being sent. For more information, see the
[Envoy documentation](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/address.proto#envoy-v3-api-msg-config-core-v3-tcpkeepalive).
2022-10-11 19:22:55 +00:00
This option only applies to remote upstream connections for mesh and terminating gateways.
2022-10-06 17:22:07 +00:00
2022-10-11 19:22:55 +00:00
- `envoy_gateway_remote_tcp_keepalive_interval` - The number of seconds between keep-alive probes.
2022-10-06 17:22:07 +00:00
For more information, see the
[Envoy documentation](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/address.proto#envoy-v3-api-msg-config-core-v3-tcpkeepalive).
2022-10-11 19:22:55 +00:00
This option only applies to remote upstream connections for mesh and terminating gateways.
2022-10-06 17:22:07 +00:00
2022-10-11 19:22:55 +00:00
- `envoy_gateway_remote_tcp_keepalive_probes` - Maximum number of keepalive probes to send without
2022-10-06 17:22:07 +00:00
response before deciding the connection is dead. For more information, see the
[Envoy documentation](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/address.proto#envoy-v3-api-msg-config-core-v3-tcpkeepalive).
2022-10-11 19:22:55 +00:00
This option only applies to remote upstream connections for mesh and terminating gateways.
2022-10-06 17:22:07 +00:00
2019-05-08 21:03:53 +00:00
## Advanced Configuration
2019-06-26 15:34:58 +00:00
To support more flexibility when configuring Envoy, several "lower-level" options exist
that require knowledge of Envoy's configuration format.
Many options allow configuring a subsection of either the bootstrap or
2019-05-08 21:03:53 +00:00
dynamic configuration using your own custom protobuf config.
We separate these into two sets, [Advanced Bootstrap
Options](#advanced-bootstrap-options) and [Escape Hatch
2019-06-26 15:34:58 +00:00
Overrides](#escape-hatch-overrides). Both require writing Envoy config in the
protobuf JSON encoding. Advanced options cover smaller chunks that might
2019-05-08 21:03:53 +00:00
commonly need to be set for tasks like configuring tracing. In contrast, escape hatches
give almost complete control over the proxy setup, but require operators to
manually code the entire configuration in protobuf JSON.
~> **Advanced Topic!** This section covers options that allow users to take almost
complete control of Envoy's configuration. We provide these options so users can
2023-05-05 17:41:40 +00:00
experiment or take advantage of features not yet fully supported in Consul service mesh. We
2019-05-08 21:03:53 +00:00
plan to retain this ability in the future, but it should still be considered
experimental because it requires in-depth knowledge of Envoy's configuration format.
Users should consider Envoy version compatibility when using these features because they can configure Envoy in ways that
are outside of Consul's control. Incorrect configuration could prevent all
proxies in your mesh from functioning correctly, or bypass the security
2023-05-05 17:41:40 +00:00
guarantees Consul service mesh is designed to enforce.
2019-05-08 21:03:53 +00:00
### Configuration Formatting
All configurations are specified as strings containing the serialized proto3 JSON encoding
of the specified Envoy configuration type. They are full JSON types except where
noted.
The JSON supplied may describe a protobuf `types.Any` message with an `@type`
field set to the appropriate type (for example
2021-06-10 15:59:54 +00:00
`type.googleapis.com/envoy.config.listener.v3.Listener`).
2019-05-08 21:03:53 +00:00
2019-11-29 17:43:42 +00:00
For example, given a tracing config:
2022-05-02 18:25:59 +00:00
<CodeBlockConfig heading="Example envoy_tracing_json configuration">
2019-11-29 17:43:42 +00:00
```json
2021-06-10 15:59:54 +00:00
{
2019-11-29 17:43:42 +00:00
"http": {
2021-06-10 15:59:54 +00:00
"name": "envoy.tracers.zipkin",
"typedConfig": {
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
"collector_cluster": "zipkin",
"collector_endpoint_version": "HTTP_JSON",
"collector_endpoint": "/api/v1/spans",
"shared_span_context": false
}
2019-11-29 17:43:42 +00:00
}
}
```
2022-05-02 18:25:59 +00:00
</CodeBlockConfig>
2019-11-29 17:43:42 +00:00
JSON escape the value of `tracing` into a string, for example using [https://codebeautify.org/json-escape-unescape](https://codebeautify.org/json-escape-unescape),
2021-06-12 22:21:07 +00:00
or using [jq](https://stedolan.github.io/jq/).
```shell
$ cat <<EOF | jq '. | @json'
{
"http": {
"name": "envoy.tracers.zipkin",
"typedConfig": {
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
"collector_cluster": "zipkin",
"collector_endpoint_version": "HTTP_JSON",
"collector_endpoint": "/api/v1/spans",
"shared_span_context": false
}
}
}
EOF
"{\"http\":{\"name\":\"envoy.tracers.zipkin\",\"typedConfig\":{\"@type\":\"type.googleapis.com/envoy.config.trace.v3.ZipkinConfig\",\"collector_cluster\":\"zipkin\",\"collector_endpoint_version\":\"HTTP_JSON\",\"collector_endpoint\":\"/api/v1/spans\",\"shared_span_context\":false}}}"
```
Then use that as the value for `envoy_tracing_json`:
2019-11-29 17:43:42 +00:00
```json
{
"kind": "proxy-defaults",
"name": "global",
"config": {
2021-06-10 15:59:54 +00:00
"envoy_tracing_json": "{\"http\":{\"name\":\"envoy.tracers.zipkin\",\"typedConfig\":{\"@type\":\"type.googleapis.com/envoy.config.trace.v3.ZipkinConfig\",\"collector_cluster\":\"zipkin\",\"collector_endpoint_version\":\"HTTP_JSON\",\"collector_endpoint\":\"/api/v1/spans\",\"shared_span_context\":false}}}\n"
2019-11-29 17:43:42 +00:00
}
}
```
If using HCL, this escaping is done automatically:
```hcl
Kind = "proxy-defaults"
Name = "global"
Config {
envoy_tracing_json = <<EOF
{
"http": {
2021-06-10 15:59:54 +00:00
"name": "envoy.tracers.zipkin",
"typedConfig": {
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
2019-11-29 17:43:42 +00:00
"collector_cluster": "zipkin",
2021-06-10 15:59:54 +00:00
"collector_endpoint_version": "HTTP_JSON",
2019-11-29 17:43:42 +00:00
"collector_endpoint": "/api/v1/spans",
"shared_span_context": false
}
}
}
EOF
}
```
2019-05-08 21:03:53 +00:00
### Advanced Bootstrap Options
Users may add the following configuration items to the [global `proxy-defaults`
configuration
2023-01-20 17:12:18 +00:00
entry](/consul/docs/connect/config-entries/proxy-defaults) or
2019-05-08 21:03:53 +00:00
override them directly in the `proxy.config` field of a [proxy service
2023-01-20 17:12:18 +00:00
definition](/consul/docs/connect/registration/service-registration) or
[`sidecar_service`](/consul/docs/connect/registration/sidecar-service) block.
2019-05-08 21:03:53 +00:00
2023-01-20 17:12:18 +00:00
- `envoy_extra_static_clusters_json` - Specifies one or more [Envoy clusters](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/cluster/v3/cluster.proto)
2019-05-08 21:03:53 +00:00
that will be appended to the array of [static
2021-06-10 15:59:54 +00:00
clusters](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-bootstrap-staticresources-clusters)
2022-05-02 18:25:59 +00:00
in the bootstrap config. This enables you to add custom clusters for tracing sinks,
for example. In order to configure a single cluster, specify a single JSON object with the cluster details. For multiple
clusters, specify objects in a comma-separated list with no trailing comma. The
cluster objects will be interpolated directly into a JSON array.
<CodeBlockConfig heading="Example envoy_extra_static_clusters_json">
```json
{
"name": "local-service-cluster",
"load_assignment": {
"cluster_name": "local-service-cluster",
"endpoints": [
{
"lb_endpoints": [
{
"endpoint": {
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": 32769
}
}
}
}
]
}
]
}
}
```
</CodeBlockConfig>
2021-06-10 15:59:54 +00:00
2019-05-08 21:03:53 +00:00
- `envoy_extra_static_listeners_json` - Similar to
2023-01-20 17:12:18 +00:00
`envoy_extra_static_clusters_json` but appends one or more [Envoy listeners](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/listener/v3/listener.proto) to the array of [static
2021-06-10 15:59:54 +00:00
listener](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-bootstrap-staticresources-listeners) definitions.
2023-05-05 17:41:40 +00:00
Can be used to setup limited access that bypasses the service mesh's mTLS or
2019-05-08 21:03:53 +00:00
authorization for health checks or metrics.
2021-06-10 15:59:54 +00:00
2022-05-02 18:25:59 +00:00
<CodeBlockConfig heading="Example envoy_extra_static_listeners_json">
```json
{
"name": "test_envoy_mtls_bypass_listener",
"address": {
"socket_address": {
"address": "0.0.0.0",
"port_value": 20201
}
},
"filter_chains": [
{
"filters": [
{
"name": "envoy.filters.network.http_connection_manager",
"typedConfig": {
"@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
"http_filters": [
{
"name": "envoy.filters.http.router"
}
],
"route_config": {
"name": "self_admin_route",
"virtual_hosts": [
{
"name": "self_admin",
"domains": [
"*"
],
"routes": [
{
"match": {
"path": "/"
},
"route": {
"cluster": "local-service-cluster"
}
}
]
}
]
},
"stat_prefix": "envoy_mtls_bypass",
"tracing": {
"random_sampling": {}
}
}
}
]
}
]
}
```
</CodeBlockConfig>
2019-05-08 21:03:53 +00:00
- `envoy_extra_stats_sinks_json` - Similar to `envoy_extra_static_clusters_json`
2021-06-10 15:59:54 +00:00
but for [stats sinks](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-bootstrap-stats-sinks).
These are appended to any sinks defined by use of the
2019-05-08 21:03:53 +00:00
higher-level [`envoy_statsd_url`](#envoy_statsd_url) or
[`envoy_dogstatsd_url`](#envoy_dogstatsd_url) config options.
2021-06-10 15:59:54 +00:00
2022-05-02 18:25:59 +00:00
<CodeBlockConfig heading="Example envoy_extra_stats_sinks_json">
```json
{
"name": "envoy.stat_sinks.dog_statsd",
"typed_config": {
"@type": "type.googleapis.com/envoy.config.metrics.v3.DogStatsdSink",
"address": {
"socket_address": {
"protocol": "UDP",
"port_value": 8125,
"address": "172.31.20.6"
}
}
}
}
```
</CodeBlockConfig>
2019-05-08 21:03:53 +00:00
- `envoy_stats_config_json` - The entire [stats
2021-06-10 15:59:54 +00:00
config](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-bootstrap-stats-config).
2019-05-08 21:03:53 +00:00
If provided this will override the higher-level
[`envoy_stats_tags`](#envoy_stats_tags). It allows full control over dynamic
tag replacements etc.
2021-06-10 15:59:54 +00:00
2022-05-02 18:25:59 +00:00
<CodeBlockConfig heading="Example envoy_stats_config_json">
```json
{
"stats_matcher": {
"reject_all": true
},
"stats_tags": [
{
"tag_name": "envoy.http_user_agent",
"regex": "^http(?=\\.).*?\\.user_agent\\.((.+?)\\.)\\w+?$"
}
],
"use_all_default_tags": false
}
```
</CodeBlockConfig>
2019-05-08 21:03:53 +00:00
- `envoy_tracing_json` - The entire [tracing
2021-06-10 15:59:54 +00:00
config](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-bootstrap-tracing).
2019-05-08 21:03:53 +00:00
Most tracing providers will also require adding static clusters to define the
endpoints to send tracing data to.
2022-05-02 18:25:59 +00:00
<CodeBlockConfig heading="Example envoy_tracing_json">
```json
{
"http": {
"name": "envoy.tracers.zipkin",
"typedConfig": {
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
"collector_cluster": "zipkin",
"collector_endpoint_version": "HTTP_JSON",
"collector_endpoint": "/api/v1/spans",
"shared_span_context": false
}
}
}
```
</CodeBlockConfig>
2019-05-08 21:03:53 +00:00
### Escape-Hatch Overrides
Users may add the following configuration items to the [global `proxy-defaults`
configuration
2023-01-20 17:12:18 +00:00
entry](/consul/docs/connect/config-entries/proxy-defaults) or
2019-05-08 21:03:53 +00:00
override them directly in the `proxy.config` field of a [proxy service
2023-01-20 17:12:18 +00:00
definition](/consul/docs/connect/registration/service-registration) or
[`sidecar_service`](/consul/docs/connect/registration/sidecar-service) block.
2019-05-08 21:03:53 +00:00
- `envoy_bootstrap_json_tpl` - Specifies a template in Go template syntax that
is used in place of [the default
2021-06-10 15:59:54 +00:00
template](https://github.com/hashicorp/consul/blob/71d45a34601423abdfc0a64d44c6a55cf88fa2fc/command/connect/envoy/bootstrap_tpl.go#L129)
2019-05-08 21:03:53 +00:00
when generating bootstrap via [`consul connect envoy`
2023-01-20 17:12:18 +00:00
command](/consul/commands/connect/envoy). The variables that are available
2019-05-08 21:03:53 +00:00
to be interpolated are [documented
2021-06-10 15:59:54 +00:00
here](https://github.com/hashicorp/consul/blob/71d45a34601423abdfc0a64d44c6a55cf88fa2fc/command/connect/envoy/bootstrap_tpl.go#L5).
2019-05-08 21:03:53 +00:00
This offers complete control of the proxy's bootstrap although major
deviations from the default template may break Consul's ability to correctly
2020-10-14 15:23:05 +00:00
manage the proxy or enforce its security model.
2021-06-10 15:59:54 +00:00
2023-01-20 17:12:18 +00:00
- `envoy_public_listener_json` - Specifies a complete [Envoy listener](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/listener/v3/listener.proto)
2019-05-08 21:03:53 +00:00
to be delivered in place of the main public listener that the proxy used to
accept inbound connections. This will be used verbatim with the following
exceptions:
2021-06-10 15:59:54 +00:00
2019-05-08 21:03:53 +00:00
- Every `FilterChain` added to the listener will have its `TlsContext`
overridden by the Connect TLS certificates and validation context. This
2023-05-05 17:41:40 +00:00
means there is no way to override the service mesh's mutual TLS for the public
2019-05-08 21:03:53 +00:00
listener.
2021-08-09 18:47:26 +00:00
- Every `FilterChain` will have the `envoy.filters.{network|http}.rbac` filter
prepended to the filters array to ensure that all inbound connections are
2023-05-05 17:41:40 +00:00
authorized by the service mesh. Before Consul 1.9.0 `envoy.ext_authz` was inserted instead.
2021-06-10 15:59:54 +00:00
2022-05-02 18:25:59 +00:00
<CodeTabs heading="Example envoy_public_listener_json" tabs={[ "HTTP", "TCP" ]}>
```json
{
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
"name": "public_listener",
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": 21002
}
},
"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",
"http_filters": [
{
"name": "envoy.filters.http.router"
}
],
"route_config": {
"name": "local_route",
"virtual_hosts": [
{
"name": "local_service",
"domains": ["*"],
"routes": [
{
"match": {
"prefix": "/"
},
"route": {
"cluster": "local-service-cluster",
}
}
]
}
]
}
}
}
]
}
],
"traffic_direction": "INBOUND"
}
```
```json
{
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
"name": "public_listener",
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": 21002
}
},
"filter_chains": [
{
"filters": [
{
"name": "envoy.filters.network.tcp_proxy",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy",
"stat_prefix": "ingress_tcp",
"cluster": "local-service-cluster"
}
}
]
}
],
"traffic_direction": "INBOUND"
}
```
</CodeTabs>
2022-10-04 20:02:28 +00:00
- `envoy_listener_tracing_json` - Specifies a [tracing
2022-08-30 06:36:06 +00:00
configuration](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-msg-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-tracing)
2022-08-31 21:14:25 +00:00
to be inserted in the proxy's public and upstreams listeners.
2022-08-30 06:36:06 +00:00
<CodeBlockConfig heading="Example envoy_listener_tracing_json">
```json
{
"@type" : "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.Tracing",
"provider" : {
"name" : "envoy.tracers.zipkin",
"typed_config" : {
"@type" : "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
"collector_cluster" : "otelcolector",
"collector_endpoint" : "/api/v2/spans",
"collector_endpoint_version" : "HTTP_JSON",
"shared_span_context" : false
}
},
"custom_tags" : [
{
"tag" : "custom_header",
"request_header" : {
"name" : "x-custom-traceid",
"default_value" : ""
}
},
{
"tag" : "alloc_id",
"environment" : {
"name" : "NOMAD_ALLOC_ID"
}
}
]
}
```
</CodeBlockConfig>
2023-01-20 17:12:18 +00:00
- `envoy_local_cluster_json` - Specifies a complete [Envoy cluster](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/cluster/v3/cluster.proto)
2019-05-08 21:03:53 +00:00
to be delivered in place of the local application cluster. This allows
customization of timeouts, rate limits, load balancing strategy etc.
2022-05-02 18:25:59 +00:00
<CodeBlockConfig heading="Example envoy_local_cluster_json">
```json
{
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
"name": "local_app",
"type": "STATIC",
"connect_timeout": "5s",
"circuit_breakers": {
"thresholds": [
{
"priority": "DEFAULT",
"max_connections": 2048
}
]
},
"load_assignment": {
"cluster_name": "local_app",
"endpoints": [
{
"lb_endpoints": [
{
"endpoint": {
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": 8080
}
}
}
}
]
}
]
}
}
```
</CodeBlockConfig>
2019-05-08 21:03:53 +00:00
The following configuration items may be overridden directly in the
`proxy.upstreams[].config` field of a [proxy service
2023-01-20 17:12:18 +00:00
definition](/consul/docs/connect/registration/service-registration) or
[`sidecar_service`](/consul/docs/connect/registration/sidecar-service) block.
2019-05-08 21:03:53 +00:00
2019-08-21 20:10:12 +00:00
~> **Note:** - When a
2023-01-20 17:12:18 +00:00
[`service-router`](/consul/docs/connect/config-entries/service-router),
[`service-splitter`](/consul/docs/connect/config-entries/service-splitter), or
[`service-resolver`](/consul/docs/connect/config-entries/service-resolver) config
2019-08-21 20:10:12 +00:00
entry exists for a service the below escape hatches are ignored and will log a
warning.
2023-01-20 17:12:18 +00:00
- `envoy_listener_json` - Specifies a complete [Listener](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/listener/v3/listener.proto)
2019-05-08 21:03:53 +00:00
to be delivered in place of the upstream listener that the proxy exposes to
the application for outbound connections. This will be used verbatim with the
following exceptions:
2021-06-10 15:59:54 +00:00
2019-05-08 21:03:53 +00:00
- Every `FilterChain` added to the listener will have its `TlsContext`
2023-05-05 17:41:40 +00:00
overridden by the service mesh TLS certificates and validation context. This
means there is no way to override the service mesh's mutual TLS for the public
2019-05-08 21:03:53 +00:00
listener.
2021-06-10 15:59:54 +00:00
2022-05-02 18:25:59 +00:00
<CodeTabs heading="Example upstream envoy_listener_json">
```json
{
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
"name": "example-service",
"address": {
"socket_address": {
"address": "0.0.0.0",
"port_value": 14000
}
},
"filter_chains": [
{
"filters": [
{
"name": "envoy.filters.network.http_connection_manager",
"typedConfig": {
"@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
"access_log": [
{
"name": "envoy.access_loggers.file",
"typedConfig": {
"@type": "type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog",
"path": "/var/log/envoy-access/example-service.log"
}
}
],
"http_filters": [
{
"name": "envoy.filters.http.router"
}
],
"route_config": {
"name": "example-service",
"virtual_hosts": [
{
"name": "example-service",
"domains": [
"*"
],
"routes": [
{
"match": {
"prefix": "/"
},
"route": {
"cluster": "example-service",
"timeout": "90s",
"retry_policy": {
"retry_on": "5xx,connect-failure",
"num_retries": 2,
"per_try_timeout": "60s"
}
}
}
]
}
]
},
"stat_prefix": "example-service",
"tracing": {
"random_sampling": {}
}
}
}
]
}
],
"traffic_direction": "OUTBOUND"
}
```
</CodeTabs>
2023-01-20 17:12:18 +00:00
- `envoy_cluster_json` - Specifies a complete [Envoy cluster](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/cluster/v3/cluster.proto)
2019-05-08 21:03:53 +00:00
to be delivered in place of the discovered upstream cluster. This allows
customization of timeouts, circuit breaking, rate limits, load balancing
strategy etc.
2020-10-14 15:23:05 +00:00
2022-05-02 18:25:59 +00:00
<CodeTabs heading="Example upstream envoy_cluster_json">
```json
{
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
"name": "example-service",
"type": "EDS",
"eds_cluster_config": {
"eds_config": {
"ads": {}
}
},
"connect_timeout": "90s",
"lb_policy": "ROUND_ROBIN",
"circuit_breakers": {
"thresholds": [
{
"priority": "DEFAULT",
"max_connections": 1024,
"max_pending_requests": 1024,
"max_requests": 1024,
"max_retries": 3
}
]
}
}
```
2023-01-31 21:30:20 +00:00
</CodeTabs>