github.com/outbrain/consul@v1.4.5/website/source/docs/connect/proxies/managed-deprecated.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Connect - Deprecated Managed Proxies" 4 sidebar_current: "docs-connect-proxies" 5 description: |- 6 Consul 1.2 launched it's Connect Beta period with a feature named Managed 7 Proxies which are now deprecated. This page describes how they worked and why 8 they are no longer supported. 9 --- 10 11 # Managed Proxy Deprecation 12 13 Consul Connect was first released as a beta feature in Consul 1.2.0. The initial 14 release included a feature called "Managed Proxies". Managed proxies were 15 Connect proxies where the proxy process was started, configured, and stopped by 16 Consul. They were enabled via basic configurations within the service 17 definition. 18 19 -> **Consul 1.3.0 deprecates Managed Proxies completely.** It's _strongly_ 20 recommended you do not build anything using Managed proxies and consider using 21 [sidecar service 22 registrations](/docs/connect/proxies/sidecar-service.html) instead. 23 24 Even though this was a beta feature, managed proxies will continue to work at 25 least until Consul 1.5 to prevent disruption to demonstration and 26 proof-of-concept deployments of Consul Connect. Anyone using managed proxies 27 though should aim to change their workflow as soon as possible to avoid issues 28 with a later upgrade. 29 30 While the current functionality will remain present for a few major releases, 31 **new and known issues will not be fixed**. 32 33 ## Deprecation Rationale 34 35 Originally managed proxies traded higher implementation complexity for an easier 36 "getting started" user experience. After seeing how Connect was investigated and 37 adopted during beta it because obvious that they were not the best trade off. 38 39 Managed proxies only really helped in local testing or VM-per-service based 40 models whereas a lot of users jumped straight to containers where they are not 41 helpful. They also add only targeted fairly basic supervisor features which 42 meant most people would want to use something else in production for consistency 43 with other workloads. So the high implementation cost of building robust process 44 supervision didn't actually benefit most real use-cases. 45 46 Instead of this Connect 1.3.0 introduces the concept of [sidecar service 47 registrations](/docs/connect/proxies/sidecar-service.html) which 48 have almost all of the benefits of simpler configuration but without any of the 49 additional process management complexity. As a result they can be used to 50 simplify configuration in both container-based and realistic production 51 supervisor settings. 52 53 ## Managed Proxy Documentation 54 55 As the managed proxy features continue to be supported for now, the rest of this 56 page will document how they work in the interim. 57 58 -> **Deprecation Note:** It's _strongly_ recommended you do not build anything 59 using Managed proxies and consider using [sidecar service 60 registrations](/docs/connect/proxies/sidecar-service.html) instead. 61 62 Managed proxies are given 63 a unique proxy-specific ACL token that allows read-only access to Connect 64 information for the specific service the proxy is representing. This ACL 65 token is more restrictive than can be currently expressed manually in 66 an ACL policy. 67 68 The default managed proxy is a basic proxy built-in to Consul and written 69 in Go. Having a basic built-in proxy allows Consul to have a sane default 70 with performance that is good enough for most workloads. In some basic 71 benchmarks, the service-to-service communication over the built-in proxy 72 could sustain 5 Gbps with sub-millisecond latency. Therefore, 73 the performance impact of even the basic built-in proxy is minimal. 74 75 Consul will be integrating with advanced proxies in the near future to support 76 more complex configurations and higher performance. The configuration below is 77 all for the built-in proxy. 78 79 -> **Security Note:** 1.) Managed proxies can only be configured 80 via agent configuration files. They _cannot_ be registered via the HTTP API. 81 And 2.) Managed proxies are not started at all if Consul is running as root. 82 Both of these default configurations help prevent arbitrary process 83 execution or privilege escalation. This behavior can be configured 84 [per-agent](/docs/agent/options.html#connect_proxy). 85 86 ### Lifecycle 87 88 The Consul agent starts managed proxies on demand and supervises them, 89 restarting them if they crash. The lifecycle of the proxy process is decoupled 90 from the agent so if the agent crashes or is restarted for an upgrade, the 91 managed proxy instances will _not_ be stopped. 92 93 Note that this behaviour while desirable in production might leave proxy 94 processes running indefinitely if you manually stop the agent and clear it's 95 data dir during testing. 96 97 To terminate a managed proxy cleanly you need to deregister the service that 98 requested it. If the agent is already stopped and will not be restarted again, 99 you may choose to locate the proxy processes and kill them manually. 100 101 While in `-dev` mode, unless a `-data-dir` is explicitly set, managed proxies 102 switch to being killed when the agent exits since it can't store state in order 103 to re-adopt them on restart. 104 105 ### Minimal Configuration 106 107 Managed proxies are configured within a 108 [service definition](/docs/agent/services.html). The simplest possible 109 managed proxy configuration is an empty configuration. This enables the 110 default managed proxy and starts a listener for that service: 111 112 ```json 113 { 114 "service": { 115 "name": "redis", 116 "port": 6379, 117 "connect": { "proxy": {} } 118 } 119 } 120 ``` 121 122 The listener is started on random port within the configured Connect 123 port range. It can be discovered using the 124 [DNS interface](/docs/agent/dns.html#connect-capable-service-lookups) 125 or 126 [Catalog API](#). 127 In most cases, service-to-service communication is established by 128 a proxy configured with upstreams (described below), which handle the 129 discovery transparently. 130 131 ### Upstream Configuration 132 133 To transparently discover and establish Connect-based connections to 134 dependencies, they must be configured with a static port on the managed 135 proxy configuration: 136 137 ```json 138 { 139 "service": { 140 "name": "web", 141 "port": 8080, 142 "connect": { 143 "proxy": { 144 "upstreams": [{ 145 "destination_name": "redis", 146 "local_bind_port": 1234 147 }] 148 } 149 } 150 } 151 } 152 ``` 153 154 In the example above, 155 "redis" is configured as an upstream with static port 1234 for service "web". 156 When a TCP connection is established on port 1234, the proxy 157 will find Connect-compatible "redis" services via Consul service discovery 158 and establish a TLS connection identifying as "web". 159 160 ~> **Security:** Any application that can communicate to the configured 161 static port will be able to masquerade as the source service ("web" in the 162 example above). You must either trust any loopback access on that port or 163 use namespacing techniques provided by your operating system. 164 165 -> **Deprecation Note:** versions 1.2.0 to 1.3.0 required specifying `upstreams` 166 as part of the opaque `config` that is passed to the proxy. However, since 167 1.3.0, the `upstreams` configuration is now specified directily under the 168 `proxy` key. Old service definitions using the nested config will continue to 169 work and have the values copied into the new location. This allows the upstreams 170 to be registered centrally rather than being part of the local-only config 171 passed to the proxy instance. 172 173 For full details of the additional configurable options available when using the 174 built-in proxy see the [built-in proxy configuration 175 reference](/docs/connect/configuration.html#built-in-proxy-options). 176 177 ### Prepared Query Upstreams 178 179 The upstream destination may also be a 180 [prepared query](/api/query.html). 181 This allows complex service discovery behavior such as connecting to 182 the nearest neighbor or filtering by tags. 183 184 For example, given a prepared query named "nearest-redis" that is 185 configured to route to the nearest Redis instance, an upstream can be 186 configured to route to this query. In the example below, any TCP connection 187 to port 1234 will attempt a Connect-based connection to the nearest Redis 188 service. 189 190 ```json 191 { 192 "service": { 193 "name": "web", 194 "port": 8080, 195 "connect": { 196 "proxy": { 197 "upstreams": [{ 198 "destination_name": "redis", 199 "destination_type": "prepared_query", 200 "local_bind_port": 1234 201 }] 202 } 203 } 204 } 205 } 206 ``` 207 208 -> **Note:** Connect does not currently support cross-datacenter 209 service communication. Therefore, prepared queries with Connect should 210 only be used to discover services within a single datacenter. See 211 [Multi-Datacenter Connect](/docs/connect/index.html#multi-datacenter) for 212 more information. 213 214 For full details of the additional configurable options available when using the 215 built-in proxy see the [built-in proxy configuration 216 reference](/docs/connect/configuration.html#built-in-proxy-options). 217 218 ### Custom Managed Proxy 219 220 [Custom proxies](/docs/connect/proxies/integrate.html) can also be 221 configured to run as a managed proxy. To configure custom proxies, specify 222 an alternate command to execute for the proxy: 223 224 ```json 225 { 226 "service": { 227 "name": "web", 228 "port": 8080, 229 "connect": { 230 "proxy": { 231 "exec_mode": "daemon", 232 "command": ["/usr/bin/my-proxy", "-flag-example"], 233 "config": { 234 "foo": "bar" 235 } 236 } 237 } 238 } 239 } 240 ``` 241 242 The `exec_mode` value specifies how the proxy is executed. The only 243 supported value at this time is "daemon". The command is the binary and 244 any arguments to execute. 245 The "daemon" mode expects a proxy to run as a long-running, blocking 246 process. It should not double-fork into the background. The custom 247 proxy should retrieve its configuration (such as the port to run on) 248 via the [custom proxy integration APIs](/docs/connect/proxies/integrate.html). 249 250 The default proxy command can be changed at an agent-global level 251 in the agent configuration. An example in HCL format is shown below. 252 253 ``` 254 connect { 255 proxy_defaults { 256 command = ["/usr/bin/my-proxy"] 257 } 258 } 259 ``` 260 261 With this configuration, all services registered without an explicit 262 proxy command will use `my-proxy` instead of the default built-in proxy. 263 264 The `config` key is an optional opaque JSON object which will be passed through 265 to the proxy via the proxy configuration endpoint to allow any configuration 266 options the proxy needs to be specified. See the [built-in proxy 267 configuration reference](/docs/connect/configuration.html#built-in-proxy-options) 268 for details of config options that can be passed when using the built-in proxy. 269 270 ### Managed Proxy Logs 271 272 Managed proxies have both stdout and stderr captured in log files in the agent's 273 `data_dir`. They can be found in 274 `<data_dir>/proxy/logs/<proxy_service_id>-std{err,out}.log`. 275 276 The built-in proxy will inherit it's log level from the agent so if the agent is 277 configured with `log_level = DEBUG`, a proxy it starts will also output `DEBUG` 278 level logs showing service discovery, certificate and authorization information. 279 280 ~> **Note:** In `-dev` mode there is no `data_dir` unless one is explicitly 281 configured so logging is disabled. You can access logs by providing the 282 [`-data-dir`](/docs/agent/options.html#_data_dir) CLI option. If a data dir is 283 configured, this will also cause proxy processes to stay running when the agent 284 terminates as described in [Lifecycle](#lifecycle).