• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
No results for ""
EXPAND ALL

EDIT ON GITHUB

Offline mode

Read time: 3 minutes
Last edited: Jan 05, 2022

Overview

This topic explains how to enable offline mode for the Relay Proxy.

Relay Proxy automatic configuration is an Enterprise feature

Relay Proxy automatic configuration is available to customers on an Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.

Benefits of offline mode

Enabling offline mode on the Relay Proxy lets you run the Relay Proxy without ever connecting it to LaunchDarkly. Instead of retrieving flag and segment values from LaunchDarkly's servers, the Relay Proxy gets them from files located on your local host or filesystem.

This allows you to run the Relay Proxy in a highly secure system, such as a FedRAMP-compliant system. By using offline mode, you can secure the Relay Proxy away from any external touchpoints.

Offline mode does not send events to LaunchDarkly

When the Relay Proxy is in offline mode, it does not send events to LaunchDarkly, and event-driven app features do not indicate new activity. For example, flag statuses and insights do not update to reflect evaluations from an offline Relay Proxy.

You should not use a persistent feature store between the Relay Proxy and your application in offline mode.

Enabling offline mode

Enabling offline mode is a two-step process. These steps appear in detail below.

You must:

  1. Create a Relay Proxy configuration in the Relay Proxy section of the Account Settings page and save its unique key.
  2. Configure your Relay Proxy instance to use the unique key from the prior step. You may do so either as a property in your Relay Proxy configuration file or as an environment variable.
Save the Relay Proxy's unique key

When you create a new Relay Proxy, LaunchDarkly assigns a unique key to it. You must save the key immediately after you create the Relay Proxy, because the key is only viewable on creation.

Here's how to create a Relay Proxy configuration in the LaunchDarkly UI:

  1. Navigate to the Account Settings page and click into the Relay Proxy tab:
The Relay Proxy tab on the Account Settings page.
The Relay Proxy tab on the Account Settings page.
  1. Click Create configuration. The Relay Proxy configuration screen appears.
  2. Give the Relay Proxy a human-readable Name.
  3. Choose a Rule from the dropdown. This rule determines what content the Relay Proxy receives.
  • All projects and environments sends changes about all projects and environments to the Relay Proxy.
  • Inline policy allows you to specify which projects and environments you can track events for. To learn more, read Writing an inline policy.
The Relay Proxy configuration screen with dropdown displayed.
The Relay Proxy configuration screen with dropdown displayed.
  1. Click Save configuration. The Relay Proxy appears on the Relay Proxy tab of the Account Settings page with its key visible.
  2. Copy and save the key somewhere secure:
The Relay Proxy screen with a newly created Relay Proxy. The key is displayed.
The Relay Proxy screen with a newly created Relay Proxy. The key is displayed.

Next, you must download all your flag rules and segments locally and tell the Relay Proxy where to find them. You do this by associating the file containing your flag rules with the Relay Proxy in a configuration file or with an environment variable.

To get your flag rules and make them accessible to the Relay Proxy:

  1. curl /relay/latest-all. This generates a file containing all your flag rules.

An example curl is below:

curl https://sdk.launchdarkly.com/relay/latest-all \
-H "Authorization: rel-EXAMPLE-RELAY-PROXY-CONFIGURATION-KEY" \
-o EXAMPLE-NAME-OF-OUTPUTTED-FILE.tar.gz
  1. Copy that file to your local host.
  2. The next step varies depending on whether you're using a configuration file or environment variables:
  • If you're using a configuration file, configure it to read the file you saved in step 2. In the file, specify an OfflineMode section with the fileDataSource key and a value of the file's path.

  • If you're using environment variables, specify the file with the FILE_DATA_SOURCE environment variable.

    [OfflineMode]
    fileDataSource = "/path/to/file.tar.gz"
  1. Start the Relay Proxy.

From now on, the Relay Proxy will serve flag values based on the contents of the file you downloaded, not by contacting LaunchDarkly for updates.

Updating flag rules in offline mode

After you configure the Relay Proxy to run in offline mode, you do not need to connect to a network to update flag rules. If your flag rules change, you can update the Relay Proxy by re-downloading the flag rules file and updating it on your filesystem.

To update the Relay Proxy in offline mode:

  1. Make a request to https://sdk.launchdarkly.com/relay/latest-all to generate a file containing all your flag rules.
  2. Replace the existing file on the Relay Proxy's filesystem with the newly-generated file. The Relay Proxy will detect that the file has changed and will reload it.

The Relay Proxy automatically updates when it detects changes to your flag rules.