For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • SDKs
    • SDK concepts
    • SDK features
      • Aliasing users
      • Anonymous contexts and users
      • Automatic environment attributes
      • Big segments
      • Bootstrapping
      • Configuration
      • Context configuration
      • Customizing AgentControl
      • Data saving mode
      • Evaluating flags
      • Flag evaluation reasons
      • Flushing events
      • Getting all flags
      • Hooks
      • Identifying and changing contexts
      • Inspectors
      • Logging configuration
      • Migrations
      • Monitoring SDK status
      • Multiple environments
      • Offline mode
      • OpenTelemetry in server-side SDKs
      • Private attributes
      • User feedback
      • Reading flags from a file
      • Relay Proxy configuration
      • Secure mode
      • Sending custom events
      • Shutting down
      • Storing data
      • Subscribing to flag changes
      • Test data sources
      • Tracking AI metrics
      • Web proxy configuration
    • Client-side SDKs
    • Server-side SDKs
    • AI SDKs
    • Edge SDKs
    • OpenFeature providers
    • Observability SDKs
    • Relay Proxy
Sign inTry it free
LogoLogo
On this page
  • Overview
  • Connecting though a web proxy
  • Client-side SDKs
  • .NET (client-side)
  • C++ (client-side)
  • Server-side SDKs
  • .NET (server-side)
  • Apex
  • Go
  • Java
  • Node.js (server-side)
  • Python
  • Ruby
  • Rust
SDKsSDK features

Web proxy configuration

Was this page helpful?
Previous

Client-side SDKs

Next
Built with

Overview

This topic explains how to configure an SDK to connect to LaunchDarkly through a web proxy. This feature is available for client-side and server-side SDKs.

Connecting to LaunchDarkly through a web proxy is not related to using LaunchDarkly’s Relay Proxy. To learn about LaunchDarkly’s Relay Proxy, read The Relay Proxy.

Connecting though a web proxy

If your organization requires that you use a web proxy to connect to external resources, you must configure your LaunchDarkly SDKs to connect through the proxy instead of connecting to LaunchDarkly directly.

Some proxies require authentication with a username and password, or with custom headers. Instructions on how to configure the SDK to send these parameters are in the SDK-specific sections.

In the following examples, the web proxy’s hostname is “my-proxy-host” and it uses port 8080. Substitute the appropriate values for your proxy. Details about each SDK’s configuration are available in the SDK-specific sections below:

  • Client-side SDKs
  • Server-side SDKs
Using a web proxy with mobile SDKs

Android, Flutter, iOS, and React Native support using a web proxy through their device operating systems (OS). You can use their onboard OS settings to configure a web proxy.

Client-side SDKs

This feature is available in the following client-side SDKs:

  • .NET (client-side)
  • C++ (client-side)

.NET (client-side)

Expand .NET (client-side) code sample

To configure the client-side .NET SDK to connect to LaunchDarkly through a web proxy:

C#
1var handler = new System.Net.Http.HttpClientHandler();
2handler.Proxy = new System.Net.WebProxy("http://my-proxy-host:8080");
3
4var config = Configuration
5 .Builder("example-mobile-key", ConfigurationBuilder.AutoEnvAttributes.Enabled)
6 .HttpMessageHandler(handler)
7 .Build();

To configure the client-side .NET SDK to connect to LaunchDarkly through a web proxy with authentication:

C#
1var handler = new System.Net.Http.HttpClientHandler();
2var proxy = new System.Net.WebProxy("http://my-proxy-host:8080");
3var credentials = new System.Net.CredentialCache();
4credentials.Add(proxy.Address, "Basic",
5 new NetworkCredential("username", "password"));
6proxy.Credentials = credentials;
7handler.Proxy = proxy;
8
9var config = Configuration
10 .Builder("example-mobile-key", ConfigurationBuilder.AutoEnvAttributes.Enabled)
11 .HttpMessageHandler(handler)
12 .Build();

C++ (client-side)

Expand C++ (client-side) code sample
Supported versions

This feature is available in the client-side C++ SDK’s version 2.x only. It is not yet available in version 3.0.

To configure the client-side C/C++ SDK to connect to LaunchDarkly through a web proxy:

C SDK v2.x (native)
1struct LDConfig *config = LDConfigNew("example-mobile-key");
2LDConfigSetProxyURI(config, "https://web-proxy.domain.com:8080");

To configure the client-side C/C++ SDK to connect to LaunchDarkly through a web proxy with authentication:

C SDK v2.x (native)
1struct LDConfig *config = LDConfigNew("example-mobile-key");
2LDConfigSetProxyURI(config, "https://username:password@web-proxy.domain.com:8080");

Server-side SDKs

  • .NET (server-side)
  • Apex
  • Go
  • Java
  • Node.js (server-side)
  • Python
  • Ruby
  • Rust

.NET (server-side)

Expand .NET (server-side) code sample

To configure the server-side .NET SDK to connect to LaunchDarkly through a web proxy:

1var proxy = new System.Net.WebProxy("http://my-proxy-host:8080");
2
3var config = Configuration.Builder("YOUR_SDK_KEY")
4 .Http(Components.HttpConfiguration().Proxy(proxy))
5 .Build();

To configure the server-side .NET SDK to connect to LaunchDarkly through a web proxy with authentication:

1var proxyUri = new Uri("http://my-proxy-host:8080")
2var proxy = new System.Net.WebProxy(proxyUri);
3var credentials = new System.Net.CredentialCache();
4credentials.Add(proxy.Address, "Basic",
5 new NetworkCredential("username", "password"));
6proxy.Credentials = credentials;
7
8var config = Configuration.Builder("YOUR_SDK_KEY")
9 .Http(Components.HttpConfiguration().Proxy(proxy))
10 .Build();

This example uses basic authentication. However, other options are supported: the proxy that you pass to the ConfigurationBuilder in the line .Http(Components.HttpConfiguration().Proxy(proxy)) can be any implementation of System.Net.IWebProxy. If you choose to use a different implementation of System.Net.IWebProxy, you may need to make corresponding configuration updates elsewhere in your system. For example, if you use Microsoft’s NTLM authentication, you may also need to enable System.Net.Security.UseManagedNtlm in your .NET project.

To learn more, read Http and HttpConfigurationBuilder.

Apex

Expand Apex code sample

The Apex bridge that provides and retrieves flag values is written in Go, and uses the default Go networking mechanisms. 

Go’s standard HTTP library recognizes the environment variables HTTP_PROXY and HTTPS_PROXY. If you set these variables, the SDK will connect through a web proxy at the URL you provide. Because the LaunchDarkly services have https: URLs, you use HTTPS_PROXY. If you are connecting to services at an insecure http: URL use HTTP_PROXY instead.

Here is an example:

$export HTTPS_PROXY=https://my-proxy-host:8080

Go

Expand Go code sample

There are two ways to specify proxy server parameters in the Go SDK.

Go’s standard HTTP library recognizes the environment variables HTTP_PROXY and HTTPS_PROXY. If you set these variables, the SDK will connect through a web proxy at the URL you provide. Because the LaunchDarkly services have https: URLs, you use HTTPS_PROXY. If you are connecting to services at an insecure http: URL, such as a Relay Proxy instance, use HTTP_PROXY instead.

Here is an example:

$export HTTPS_PROXY=https://my-proxy-host:8080

You can also specify a proxy programmatically through the SDK configuration:

Go SDK v6.0
1import (
2 ld "github.com/launchdarkly/go-server-sdk/v6"
3 "github.com/launchdarkly/go-server-sdk/v6/ldcomponents"
4)
5
6var config ld.Config
7config.HTTP = ldcomponents.HTTPConfiguration().
8 ProxyURL("https://my-proxy-host:8080")

Java

Expand Java code sample

To configure the Java SDK to connect to LaunchDarkly through a web proxy:

Java
1LDConfig config = new LDConfig.Builder()
2 .http(Components.httpConfiguration().proxyHostAndPort("my-proxy-host", 8080))
3 .build();

To configure the Java SDK to connect to LaunchDarkly through a web proxy with authentication:

Java
1LDConfig config = new LDConfig.Builder()
2 .http(Components.httpConfiguration()
3 .proxyHostAndPort("my-proxy-host", 8080)
4 .proxyAuth(Components.httpBasicAuthentication("username", "password")))
5 .build();

Node.js (server-side)

Expand Node.js (server-side) code sample

To configure the server-side Node.js SDK to connect to LaunchDarkly through a web proxy:

1import { LDOptions } from '@launchdarkly/node-server-sdk';
2
3const options: LDOptions = {
4 proxyOptions: {
5 host: 'your-proxy-host',
6 port: 8080,
7 scheme: 'https'
8 }
9};

To configure the server-side Node.js SDK to connect to LaunchDarkly through a web proxy with authentication:

1import { LDOptions } from '@launchdarkly/node-server-sdk';
2
3const options: LDOptions = {
4 proxyOptions: {
5 host: 'your-proxy-host',
6 port: 8080,
7 scheme: 'https',
8 auth: 'username:password'
9 }
10};

To learn more, read proxyOptions.

Python

Expand Python code sample

There are two ways to specify proxy server parameters in the Python SDK.

Python’s standard HTTP library recognizes the environment variables HTTP_PROXY and HTTPS_PROXY. If you set these variables, the SDK will connect through a web proxy at the URL you provide. Because the LaunchDarkly services have https: URLs, you use HTTPS_PROXY. If you are connecting to services at an insecure http: URL, such as a Relay Proxy instance, use HTTP_PROXY instead.

How to set the HTTPS_PROXY environment variable on Mac/Linux and Windows systems:

$export HTTPS_PROXY=https://my-proxy-host:8080

Or it can be set from within Python:

Python
1os.environ["HTTPS_PROXY"] = "https://my-proxy-host:8080"

Ruby

Expand Ruby code sample

There are two ways to specify proxy server parameters in the Ruby SDK.

Ruby’s standard HTTP library recognizes the environment variables HTTP_PROXY and HTTPS_PROXY. If you set these variables, the SDK will connect through a web proxy at the URL you provide. Because the LaunchDarkly services have https: URLs, you use HTTPS_PROXY. If you are connecting to services at an insecure http: URL, such as a Relay Proxy instance, use HTTP_PROXY instead.

To configure the Ruby SDK to connect to LaunchDarkly through a web proxy:

$export HTTPS_PROXY=https://my-proxy-host:8080

Or it can be set from within Ruby:

Ruby
1ENV['HTTPS_PROXY'] = 'https://my-proxy-host:8080'

Rust

Expand Rust code sample
Supported versions

This feature is available in the Rust SDK’s version 3.0 and later.

Starting in version 3.0, the Rust SDK’s transport layer automatically detects proxy settings from environment variables. The SDK supports HTTP_PROXY, HTTPS_PROXY, and NO_PROXY. Lowercase variants take precedence over uppercase.

The proxy routing behavior is:

  • Both HTTP_PROXY and HTTPS_PROXY set: HTTP requests use HTTP_PROXY, HTTPS requests use HTTPS_PROXY.
  • Only HTTP_PROXY set: All requests, including HTTPS, route through HTTP_PROXY.
  • Only HTTPS_PROXY set: Only HTTPS requests use the proxy. HTTP requests connect directly.
  • Neither set: All requests connect directly with no proxy.

Use NO_PROXY to bypass the proxy for specific hosts. It accepts a comma-separated list of host names or * to disable the proxy for all hosts.

Here is an example:

Console
$export HTTPS_PROXY=https://my-proxy-host:8080

To configure the Rust SDK to connect to LaunchDarkly through a web proxy with authentication, include the credentials in the proxy URL:

Console
$export HTTPS_PROXY="https://username:password@my-proxy-host:8080"

You can also configure a proxy programmatically, or disable proxy support entirely:

Rust
1use launchdarkly_sdk_transport::HyperTransport;
2
3// Use a custom proxy URL
4let transport = HyperTransport::builder()
5 .proxy_url("https://my-proxy-host:8080".to_string())
6 .build_http()?;
7
8// Disable proxy completely
9let transport = HyperTransport::builder()
10 .disable_proxy()
11 .build_http()?;