Registering a service proxy in Consul does not launch it. You still need to start the proxy process (either Consul’s built-in proxy or an external proxy such as Envoy).
| Task | Description |
|---|---|
| 1. Register the proxy | Add a connect.sidecar_service stanza in your service config |
| 2. Start the proxy | Launch with consul connect proxy -sidecar-for <service> |
1. Registering via Configuration File
Instead of the HTTP API, declare your sidecar proxy in the same JSON or HCL file as your primary service. Include aconnect block with an empty sidecar_service object:
"name": Service identifier (e.g.,front-end-ecommerce)."port": Port your application listens on."connect.sidecar_service": {}: Signals Consul to register an integrated sidecar proxy.
2. Adding Upstream Dependencies
Declare downstream services underproxy.upstreams within the sidecar_service block:
"id": Unique instance identifier."tags": Metadata (version, environment)."address": If empty, defaults to the local agent address."connect.sidecar_service.proxy.upstreams": List of target services."destination_name": Consul-registered name of the downstream service.
To add more dependencies, append additional objects to the
upstreams list.3. Deploying and Starting the Sidecar Proxy
- Place your JSON file in Consul’s configuration directory (e.g.,
/etc/consul.d/). - Reload or restart the Consul agent:
consul reload- or
systemctl restart consul
- Launch the proxy process:
consul connect proxy -sidecar-for front-end-ecommerce