2018-10-11 09:44:42 +00:00
---
2020-04-07 18:55:19 +00:00
layout: docs
page_title: Connect - Deprecated Managed Proxies
2018-10-11 09:44:42 +00:00
description: |-
2020-10-14 15:23:05 +00:00
Consul 1.2 launched its Connect Beta period with a feature named Managed
2018-10-26 17:55:12 +00:00
Proxies which are now deprecated. This page describes how they worked and why
2018-10-11 09:44:42 +00:00
they are no longer supported.
---
# Managed Proxy Deprecation
Consul Connect was first released as a beta feature in Consul 1.2.0. The initial
release included a feature called "Managed Proxies". Managed proxies were
Connect proxies where the proxy process was started, configured, and stopped by
Consul. They were enabled via basic configurations within the service
definition.
2020-04-06 20:27:35 +00:00
!> **Consul 1.6.0 removes Managed Proxies completely.**
2019-08-09 19:19:30 +00:00
This documentation is provided for prior versions only. You may consider using
2018-10-11 09:44:42 +00:00
[sidecar service
2020-04-09 23:46:54 +00:00
registrations](/docs/connect/proxies/sidecar-service) instead.
2018-10-11 09:44:42 +00:00
2019-08-09 19:19:30 +00:00
Managed proxies have been deprecated since Consul 1.3 and have been fully removed
in Consul 1.6. Anyone using Managed Proxies should aim to change their workflow
as soon as possible to avoid issues with a later upgrade.
2020-04-09 23:46:54 +00:00
After transitioning away from all managed proxy usage, the `proxy` subdirectory inside [`data_dir`](/docs/agent/options#_data_dir) (specified in Consul config) can be deleted to remove extraneous configuration files and free up disk space.
2018-10-11 09:44:42 +00:00
**new and known issues will not be fixed**.
## Deprecation Rationale
Originally managed proxies traded higher implementation complexity for an easier
"getting started" user experience. After seeing how Connect was investigated and
2020-10-23 14:54:16 +00:00
adopted during beta it became obvious that they were not the best trade off.
2018-10-11 09:44:42 +00:00
Managed proxies only really helped in local testing or VM-per-service based
models whereas a lot of users jumped straight to containers where they are not
helpful. They also add only targeted fairly basic supervisor features which
meant most people would want to use something else in production for consistency
with other workloads. So the high implementation cost of building robust process
supervision didn't actually benefit most real use-cases.
Instead of this Connect 1.3.0 introduces the concept of [sidecar service
2020-04-09 23:46:54 +00:00
registrations](/docs/connect/proxies/sidecar-service) which
2018-10-11 09:44:42 +00:00
have almost all of the benefits of simpler configuration but without any of the
additional process management complexity. As a result they can be used to
simplify configuration in both container-based and realistic production
supervisor settings.
## Managed Proxy Documentation
As the managed proxy features continue to be supported for now, the rest of this
page will document how they work in the interim.
-> **Deprecation Note:** It's _strongly_ recommended you do not build anything
using Managed proxies and consider using [sidecar service
2020-04-09 23:46:54 +00:00
registrations](/docs/connect/proxies/sidecar-service) instead.
2018-10-11 09:44:42 +00:00
Managed proxies are given
a unique proxy-specific ACL token that allows read-only access to Connect
information for the specific service the proxy is representing. This ACL
token is more restrictive than can be currently expressed manually in
an ACL policy.
The default managed proxy is a basic proxy built-in to Consul and written
2021-07-02 16:18:46 +00:00
in Go. Having a basic built-in proxy allows Consul to have a reasonable default
2018-10-11 09:44:42 +00:00
with performance that is good enough for most workloads. In some basic
benchmarks, the service-to-service communication over the built-in proxy
could sustain 5 Gbps with sub-millisecond latency. Therefore,
the performance impact of even the basic built-in proxy is minimal.
Consul will be integrating with advanced proxies in the near future to support
more complex configurations and higher performance. The configuration below is
all for the built-in proxy.
-> **Security Note:** 1.) Managed proxies can only be configured
via agent configuration files. They _cannot_ be registered via the HTTP API.
And 2.) Managed proxies are not started at all if Consul is running as root.
Both of these default configurations help prevent arbitrary process
execution or privilege escalation. This behavior can be configured
2020-09-01 15:14:13 +00:00
[per-agent](/docs/agent/options).
2018-10-11 09:44:42 +00:00
### Lifecycle
The Consul agent starts managed proxies on demand and supervises them,
restarting them if they crash. The lifecycle of the proxy process is decoupled
from the agent so if the agent crashes or is restarted for an upgrade, the
managed proxy instances will _not_ be stopped.
2021-06-16 20:13:32 +00:00
Note that this behavior while desirable in production might leave proxy
2020-10-14 15:23:05 +00:00
processes running indefinitely if you manually stop the agent and clear its
2018-10-11 09:44:42 +00:00
data dir during testing.
To terminate a managed proxy cleanly you need to deregister the service that
requested it. If the agent is already stopped and will not be restarted again,
you may choose to locate the proxy processes and kill them manually.
While in `-dev` mode, unless a `-data-dir` is explicitly set, managed proxies
switch to being killed when the agent exits since it can't store state in order
to re-adopt them on restart.
### Minimal Configuration
Managed proxies are configured within a
2020-04-09 23:46:54 +00:00
[service definition](/docs/agent/services). The simplest possible
2018-10-11 09:44:42 +00:00
managed proxy configuration is an empty configuration. This enables the
default managed proxy and starts a listener for that service:
```json
{
"service": {
"name": "redis",
"port": 6379,
"connect": { "proxy": {} }
}
}
```
The listener is started on random port within the configured Connect
port range. It can be discovered using the
2020-11-17 15:03:00 +00:00
[DNS interface](/docs/discovery/dns#connect-capable-service-lookups)
2018-10-11 09:44:42 +00:00
or
[Catalog API](#).
In most cases, service-to-service communication is established by
a proxy configured with upstreams (described below), which handle the
discovery transparently.
### Upstream Configuration
To transparently discover and establish Connect-based connections to
dependencies, they must be configured with a static port on the managed
proxy configuration:
```json
{
"service": {
"name": "web",
"port": 8080,
"connect": {
"proxy": {
2020-04-06 20:27:35 +00:00
"upstreams": [
{
"destination_name": "redis",
"local_bind_port": 1234
}
]
2018-10-11 09:44:42 +00:00
}
}
}
}
```
In the example above,
"redis" is configured as an upstream with static port 1234 for service "web".
When a TCP connection is established on port 1234, the proxy
will find Connect-compatible "redis" services via Consul service discovery
and establish a TLS connection identifying as "web".
~> **Security:** Any application that can communicate to the configured
static port will be able to masquerade as the source service ("web" in the
example above). You must either trust any loopback access on that port or
use namespacing techniques provided by your operating system.
-> **Deprecation Note:** versions 1.2.0 to 1.3.0 required specifying `upstreams`
as part of the opaque `config` that is passed to the proxy. However, since
2021-06-16 20:13:32 +00:00
1.3.0, the `upstreams` configuration is now specified directly under the
2018-10-11 09:44:42 +00:00
`proxy` key. Old service definitions using the nested config will continue to
work and have the values copied into the new location. This allows the upstreams
to be registered centrally rather than being part of the local-only config
passed to the proxy instance.
For full details of the additional configurable options available when using the
built-in proxy see the [built-in proxy configuration
2020-09-01 15:14:13 +00:00
reference](/docs/connect/configuration).
2018-10-11 09:44:42 +00:00
### Prepared Query Upstreams
The upstream destination may also be a
2020-04-09 23:46:54 +00:00
[prepared query](/api/query).
2018-10-11 09:44:42 +00:00
This allows complex service discovery behavior such as connecting to
the nearest neighbor or filtering by tags.
For example, given a prepared query named "nearest-redis" that is
configured to route to the nearest Redis instance, an upstream can be
configured to route to this query. In the example below, any TCP connection
to port 1234 will attempt a Connect-based connection to the nearest Redis
service.
```json
{
"service": {
"name": "web",
"port": 8080,
"connect": {
"proxy": {
2020-04-06 20:27:35 +00:00
"upstreams": [
{
"destination_name": "redis",
"destination_type": "prepared_query",
"local_bind_port": 1234
}
]
2018-10-11 09:44:42 +00:00
}
}
}
}
```
For full details of the additional configurable options available when using the
built-in proxy see the [built-in proxy configuration
2020-09-01 15:14:13 +00:00
reference](/docs/connect/configuration).
2018-10-11 09:44:42 +00:00
### Custom Managed Proxy
2020-04-09 23:46:54 +00:00
[Custom proxies](/docs/connect/proxies/integrate) can also be
2018-10-11 09:44:42 +00:00
configured to run as a managed proxy. To configure custom proxies, specify
an alternate command to execute for the proxy:
```json
{
"service": {
"name": "web",
"port": 8080,
"connect": {
"proxy": {
"exec_mode": "daemon",
2020-04-06 20:27:35 +00:00
"command": ["/usr/bin/my-proxy", "-flag-example"],
2018-10-11 09:44:42 +00:00
"config": {
"foo": "bar"
}
}
}
}
}
```
The `exec_mode` value specifies how the proxy is executed. The only
supported value at this time is "daemon". The command is the binary and
any arguments to execute.
The "daemon" mode expects a proxy to run as a long-running, blocking
process. It should not double-fork into the background. The custom
proxy should retrieve its configuration (such as the port to run on)
2020-04-09 23:46:54 +00:00
via the [custom proxy integration APIs](/docs/connect/proxies/integrate).
2018-10-11 09:44:42 +00:00
The default proxy command can be changed at an agent-global level
in the agent configuration. An example in HCL format is shown below.
```
connect {
proxy_defaults {
command = ["/usr/bin/my-proxy"]
}
}
```
With this configuration, all services registered without an explicit
proxy command will use `my-proxy` instead of the default built-in proxy.
The `config` key is an optional opaque JSON object which will be passed through
to the proxy via the proxy configuration endpoint to allow any configuration
options the proxy needs to be specified. See the [built-in proxy
2020-09-01 15:14:13 +00:00
configuration reference](/docs/connect/configuration)
2018-10-11 09:44:42 +00:00
for details of config options that can be passed when using the built-in proxy.
### Managed Proxy Logs
Managed proxies have both stdout and stderr captured in log files in the agent's
`data_dir`. They can be found in
`<data_dir>/proxy/logs/<proxy_service_id>-std{err,out}.log`.
2020-10-14 15:23:05 +00:00
The built-in proxy will inherit its log level from the agent so if the agent is
2018-10-11 09:44:42 +00:00
configured with `log_level = DEBUG`, a proxy it starts will also output `DEBUG`
level logs showing service discovery, certificate and authorization information.
~> **Note:** In `-dev` mode there is no `data_dir` unless one is explicitly
configured so logging is disabled. You can access logs by providing the
2020-04-09 23:46:54 +00:00
[`-data-dir`](/docs/agent/options#_data_dir) CLI option. If a data dir is
2018-10-11 09:44:42 +00:00
configured, this will also cause proxy processes to stay running when the agent
2019-05-16 11:48:32 +00:00
terminates as described in [Lifecycle](#lifecycle).