> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Web proxy configuration

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

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 the Relay Proxy. To learn about the Relay Proxy, read [The Relay Proxy](/docs/sdk/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](#client-side-sdks)
* [Server-side SDKs](#server-side-sdks)

<Note>
  **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.
</Note>

## Client-side SDKs

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

* [.NET (client-side)](#net-client-side)
* [C++ (client-side)](#c++-client-side)

### .NET (client-side)

<Accordion title="Expand .NET (client-side) code sample">
  To configure the client-side .NET SDK to connect to LaunchDarkly through a web proxy:

  <CodeGroup>
    ```csharp title="C#" lines wrap theme={null}
    var handler = new System.Net.Http.HttpClientHandler();
    handler.Proxy = new System.Net.WebProxy("http://my-proxy-host:8080");

    var config = Configuration
        .Builder("example-mobile-key", ConfigurationBuilder.AutoEnvAttributes.Enabled)
        .Http(Components.HttpConfiguration().MessageHandler(handler))
        .Build();
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```csharp title="C#" lines wrap theme={null}
    var handler = new System.Net.Http.HttpClientHandler();
    var proxy = new System.Net.WebProxy("http://my-proxy-host:8080");
    var credentials = new System.Net.CredentialCache();
    credentials.Add(proxy.Address, "Basic",
        new NetworkCredential("username", "password"));
    proxy.Credentials = credentials;
    handler.Proxy = proxy;

    var config = Configuration
        .Builder("example-mobile-key", ConfigurationBuilder.AutoEnvAttributes.Enabled)
        .Http(Components.HttpConfiguration().MessageHandler(handler))
        .Build();
    ```
  </CodeGroup>
</Accordion>

### C++ (client-side)

<Accordion title="Expand C++ (client-side) code sample">
  <Note>
    **Supported versions**

    This feature is available starting in version 3.11. It requires an SDK build with curl networking enabled (`-DLD_CURL_NETWORKING=ON`).
  </Note>

  The SDK supports HTTP, HTTPS, and SOCKS proxies. If you do not configure a proxy explicitly, the SDK uses curl's proxy environment variables (`ALL_PROXY`, `HTTP_PROXY`, `HTTPS_PROXY`). To disable proxy usage, including the environment variables, set the proxy to an empty string.

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

  <CodeGroup>
    ```cpp title="C++ SDK v3.11+ (native)" lines wrap theme={null}
    // Requires an SDK build with -DLD_CURL_NETWORKING=ON.
    auto config_builder = client_side::ConfigBuilder("example-mobile-key");
    config_builder.HttpProperties().Proxy("https://web-proxy.domain.com:8080");
    ```

    ```c title="C++ SDK v3.11+ (C binding)" lines wrap theme={null}
    /* Requires an SDK build with -DLD_CURL_NETWORKING=ON. */
    LDClientConfigBuilder builder = LDClientConfigBuilder_New("example-mobile-key");
    LDClientConfigBuilder_HttpProperties_Proxy(builder, "https://web-proxy.domain.com:8080");
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```cpp title="C++ SDK v3.11+ (native)" lines wrap theme={null}
    // Requires an SDK build with -DLD_CURL_NETWORKING=ON.
    auto config_builder = client_side::ConfigBuilder("example-mobile-key");
    config_builder.HttpProperties().Proxy(
        "https://username:password@web-proxy.domain.com:8080");
    ```

    ```c title="C++ SDK v3.11+ (C binding)" lines wrap theme={null}
    /* Requires an SDK build with -DLD_CURL_NETWORKING=ON. */
    LDClientConfigBuilder builder = LDClientConfigBuilder_New("example-mobile-key");
    LDClientConfigBuilder_HttpProperties_Proxy(
        builder, "https://username:password@web-proxy.domain.com:8080");
    ```
  </CodeGroup>
</Accordion>

## Server-side SDKs

* [.NET (server-side)](#net-server-side)
* [Apex](#apex)
* [Go](#go)
* [Java](#java)
* [Node.js (server-side)](#node-js-server-side)
* [Python](#python)
* [Ruby](#ruby)
* [Rust](#rust)

### .NET (server-side)

<Accordion title="Expand .NET (server-side) code sample">
  To configure the server-side .NET SDK to connect to LaunchDarkly through a web proxy:

  <CodeGroup>
    ```csharp title="C#" lines wrap theme={null}
    var proxy = new System.Net.WebProxy("http://my-proxy-host:8080");

    var config = Configuration.Builder("YOUR_SDK_KEY")
        .Http(Components.HttpConfiguration().Proxy(proxy))
        .Build();
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```csharp title="C#" lines wrap theme={null}
    var proxyUri = new Uri("http://my-proxy-host:8080");
    var proxy = new System.Net.WebProxy(proxyUri);
    var credentials = new System.Net.CredentialCache();
    credentials.Add(proxy.Address, "Basic",
        new NetworkCredential("username", "password"));
    proxy.Credentials = credentials;

    var config = Configuration.Builder("YOUR_SDK_KEY")
        .Http(Components.HttpConfiguration().Proxy(proxy))
        .Build();
    ```
  </CodeGroup>

  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](https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/ntlm-user-authentication), you may also need to enable `System.Net.Security.UseManagedNtlm` in your .NET project.

  To learn more, read [`Http`](https://launchdarkly.github.io/dotnet-core/pkgs/sdk/server/api/LaunchDarkly.Sdk.Server.ConfigurationBuilder.html#LaunchDarkly_Sdk_Server_ConfigurationBuilder_Http_LaunchDarkly_Sdk_Server_Subsystems_IComponentConfigurer_LaunchDarkly_Sdk_Server_Subsystems_HttpConfiguration__) and [`HttpConfigurationBuilder`](https://launchdarkly.github.io/dotnet-core/pkgs/sdk/server/api/LaunchDarkly.Sdk.Server.Integrations.HttpConfigurationBuilder.html).
</Accordion>

### Apex

<Accordion title="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:

  <CodeGroup>
    ```bash title="Console" lines wrap theme={null}
    export HTTPS_PROXY=https://my-proxy-host:8080
    ```

    ```batch title="cmd" lines wrap theme={null}
    set HTTPS_PROXY=https://my-proxy-host:8080
    ```
  </CodeGroup>
</Accordion>

### Go

<Accordion title="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:

  <CodeGroup>
    ```bash title="Console" lines wrap theme={null}
    export HTTPS_PROXY=https://my-proxy-host:8080
    ```

    ```text title="cmd" lines wrap theme={null}
    set HTTPS_PROXY=https://my-proxy-host:8080
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```go title="Go SDK v6+" lines wrap theme={null}
    import (
        ld "github.com/launchdarkly/go-server-sdk/v6"
        "github.com/launchdarkly/go-server-sdk/v6/ldcomponents"
    )

    var config ld.Config
    config.HTTP = ldcomponents.HTTPConfiguration().
        ProxyURL("https://my-proxy-host:8080")
    ```
  </CodeGroup>
</Accordion>

### Java

<Accordion title="Expand Java code sample">
  To configure the Java SDK to connect to LaunchDarkly through a web proxy:

  <CodeGroup>
    ```java title="Java" lines wrap theme={null}
    LDConfig config = new LDConfig.Builder()
      .http(Components.httpConfiguration().proxyHostAndPort("my-proxy-host", 8080))
      .build();
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```java title="Java" lines wrap theme={null}
    LDConfig config = new LDConfig.Builder()
      .http(Components.httpConfiguration()
        .proxyHostAndPort("my-proxy-host", 8080)
        .proxyAuth(Components.httpBasicAuthentication("username", "password")))
      .build();
    ```
  </CodeGroup>
</Accordion>

### Node.js (server-side)

<Accordion title="Expand Node.js (server-side) code sample">
  To configure the server-side Node.js SDK to connect to LaunchDarkly through a web proxy:

  <CodeGroup>
    ```ts title="Node.js SDK v8.x+ (TypeScript)" lines wrap theme={null}
    import { LDOptions } from '@launchdarkly/node-server-sdk';

    const options: LDOptions = {
      proxyOptions: {
          host: 'your-proxy-host',
          port: 8080,
          scheme: 'https'
        }
    };
    ```

    ```js title="Node.js SDK v8.x+ (JavaScript)" lines wrap theme={null}
    const options = {
      proxyOptions: {
          host: 'your-proxy-host',
          port: 8080,
          scheme: 'https'
        }
    };
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```ts title="Node.js SDK v8.x+ (TypeScript)" lines wrap theme={null}
    import { LDOptions } from '@launchdarkly/node-server-sdk';

    const options: LDOptions = {
      proxyOptions: {
          host: 'your-proxy-host',
          port: 8080,
          scheme: 'https',
          auth: 'username:password'
        }
    };
    ```

    ```js title="Node.js SDK v8.x+ (JavaScript)" lines wrap theme={null}

    const options = {
      proxyOptions: {
          host: 'your-proxy-host',
          port: 8080,
          scheme: 'https',
          auth: 'username:password'
        }
    };
    ```
  </CodeGroup>

  To learn more, read [`proxyOptions`](https://launchdarkly.github.io/js-core/packages/sdk/server-node/docs/interfaces/LDOptions.html#proxyOptions).
</Accordion>

### Python

<Accordion title="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:

  <CodeGroup>
    ```bash title="Console" lines wrap theme={null}
    export HTTPS_PROXY=https://my-proxy-host:8080
    ```

    ```bash title="cmd" lines wrap theme={null}
    set HTTPS_PROXY=https://my-proxy-host:8080
    ```
  </CodeGroup>

  Or it can be set from within Python:

  <CodeGroup>
    ```python title="Python" lines wrap theme={null}
    import os

    os.environ["HTTPS_PROXY"] = "https://my-proxy-host:8080"
    ```
  </CodeGroup>
</Accordion>

### Ruby

<Accordion title="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:

  <CodeGroup>
    ```bash title="Console" lines wrap theme={null}
    export HTTPS_PROXY=https://my-proxy-host:8080
    ```

    ```batch title="cmd" lines wrap theme={null}
    set HTTPS_PROXY=https://my-proxy-host:8080
    ```
  </CodeGroup>

  Or it can be set from within Ruby:

  <CodeGroup>
    ```ruby title="Ruby" lines wrap theme={null}
    ENV['HTTPS_PROXY'] = 'https://my-proxy-host:8080'
    ```
  </CodeGroup>
</Accordion>

### Rust

<Accordion title="Expand Rust code sample">
  <Note>
    **Supported versions**

    This feature is available in the Rust SDK's version 3.0 and later.
  </Note>

  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:

  <CodeGroup>
    ```bash title="Console" lines wrap theme={null}
    export HTTPS_PROXY=https://my-proxy-host:8080
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```bash title="Console" lines wrap theme={null}
    export HTTPS_PROXY="https://username:password@my-proxy-host:8080"
    ```
  </CodeGroup>

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

  <CodeGroup>
    ```rust title="Rust" lines wrap theme={null}
    use launchdarkly_sdk_transport::HyperTransport;

    // Use a custom proxy URL
    let transport = HyperTransport::builder()
        .proxy_url("https://my-proxy-host:8080".to_string())
        .build_http()?;

    // Disable proxy completely
    let transport = HyperTransport::builder()
        .disable_proxy()
        .build_http()?;
    ```
  </CodeGroup>
</Accordion>
