Configuring the Relay Proxy
After you have downloaded or built the Relay Proxy, you need to set its configuration options. You can set these options by either:- using a configuration file, or
- using environment variables.
Request metrics only appear after an SDK connectsSome of the Relay Proxy configuration options enable you to export metrics, including the number of connections and requests. Request and connection metrics have no data until an SDK sends a request to the Relay Proxy. In version 9.0 and later, status metrics are exported whenever metric export is on. To learn more, read the Relay Proxy GitHub repository’s Metrics.
Expand Using a configuration file
Expand Using a configuration file
Using a configuration file
It’s common to use a configuration file when you deploy the Relay Proxy from a release binary or build it from source.You can also use a configuration file when you run the Relay Proxy from a Docker container, but it is less convenient to do because you must place the configuration file at/ldr/ld-relay.conf.To learn more about the supported configuration options, read the Relay Proxy GitHub repository’s Configuration docs. To learn about Relay Proxy logging level options, read Logging.To use a configuration file:-
Create a new file:
-
Run the Relay Proxy binary while passing an argument to identify your configuration file’s location. The following example assumes that the configuration file is in your current directory and named
ld-relay.conf, and that theld-relaybinary is in$GOPATH/bin. Run the following code:
Expand Using environment variables
Expand Using environment variables
Using environment variables
The other way to configure your Relay Proxy is with environment variables. This method is available regardless of how you deploy the Relay Proxy, although it is most commonly used with Docker containers.To learn more about supported environment variables, read the Relay Proxy GitHub repository’s Configuration file format and environment variables. To learn about Relay Proxy logging level options, read Logging.To use environment variables:-
Confirm that all of your Relay Proxy configuration values are specified with the appropriate environment variables.
For example, to specify the SDK key for an environment named
MyEnvName: -
Run the Relay Proxy binary while passing the
--from-envargument. The following command assumes that theld-relaybinary is in$GOPATH/bin.
Deploying the Relay Proxy
You can deploy the Relay Proxy in one of four ways. In order from most common to least common, the methods are:- starting the Relay Proxy from a Docker image,
- using Helm to run the Relay Proxy in Kubernetes,
- downloading a Relay Proxy standalone release binary, or
- building within an existing Go app.
Expand Starting the Relay Proxy from a Docker image
Expand Starting the Relay Proxy from a Docker image
Starting the Relay Proxy from a Docker image
The Relay Proxy’s Docker images are based on Google’s Debian 13 “Distroless” images. Distroless images contain the Relay Proxy and its runtime dependencies, without a shell or package manager. The images run as the distrolessnonroot user, ID 65532. Make sure that user can read any files you mount into the container, such as a configuration file or an offline mode archive.The images are available on Docker Hub for amd64, arm64, and armv7. A debug variant includes a BusyBox shell at /busybox/sh for troubleshooting. For more information, read Using with Docker.Relay Proxy 8.x also publishes Alpine images, and its distroless images are based on Debian 12. Version 9.0 and later publish only the Debian 13 distroless images. To learn more, read Relay Proxy 8.x to 9.0 migration guide.To deploy the Relay Proxy with Docker:- Use
docker pullto pull the latest Relay Proxy Docker image:
v9- pattern floats the minor and patch versions of the Relay Proxy. You may also pin to a specific version, such as launchdarkly/ld-relay:9.0.0-static-debian13-nonroot.- Use
docker runto run the Relay Proxy from your Docker container while specifying your configuration details.
-e option of docker run. An example configuration that uses environment variables appears below.For examples and a full list of allowable variables, read the Relay Proxy GitHub repository’s Using with Docker and SDK configuration.In the following example, the Relay Proxy has two LaunchDarkly environments.For the first environment, the SDK key is staging-YOUR_SDK_KEY, and the environment name, for the purposes of logging, is Staging. For the second environment, the SDK key is prod-sdk-key-456def, and the environment name is Production.In this example, the Relay Proxy is configured to listen on port 8030, which is its default port.The example configuration follows:Expand Using Helm to run the Relay Proxy in Kubernetes
Expand Using Helm to run the Relay Proxy in Kubernetes
Using Helm to run the Relay Proxy in Kubernetes
We maintain a Helm chart to ease Kubernetes-based Relay Proxy deployments.To deploy the Relay Proxy using this Helm chart:-
Add the LaunchDarkly Relay Proxy Helm chart repository.
-
Use
helm installto install the chart archive and deploy the proxy into your cluster. The fastest way to configure installation is through Helm’s--setflag. However, we recommend using files with the--valuesflag as this enables easier long term maintenance. In the examples below, replaceMyEnvironmentwith the name of your Relay Proxy environment andsdk-keywith your SDK key.
Expand Downloading a Relay Proxy standalone release binary
Expand Downloading a Relay Proxy standalone release binary
Downloading a Relay Proxy standalone release binary
You can download one of the Relay Proxy’s most recent release binaries from our GitHub repository. This repository has all versions of the Relay Proxy releases with details about what each release improves or fixes. We recommend using the most recent release.To learn more about Relay Proxy release binaries, visit the GitHub repository.If you want to download a release binary from the GitHub repository, you should know the following things:- tar.gz files are executables. You can use these to run the Relay Proxy directly.
- .deb and .rpm files are intended for use with a package manager.
Expand Building within an existing Go app
Expand Building within an existing Go app
Building within an existing Go app
To build the Relay Proxy from source:- Install Go 1.26 or higher. To install Go, read Go’s documentation.
- Clone the default branch of the repository: https://github.com/launchdarkly/ld-relay
- Run
go build .in the directory where you cloned the code.
ld-relay appears in the directory.There is also a shortcut command that can replace the longer procedure above. This command downloads the code and builds it in a single step. After you enter the command, the executable binary ld-relay appears in $GOPATH/bin. You can move it to any other location.