All Products
Search
Document Center

Alibaba Cloud SDK:Configure a proxy

Last Updated:Aug 31, 2026

In software development, a proxy acts as an intermediary that controls access to a feature or resource. By using a proxy, you can implement capabilities such as permission checks, operation logs, cached data, and lazy loading without modifying your existing code. This makes your application more secure and faster, and easier to maintain and extend. This topic describes how to configure a proxy in .NET SDK V2.0.

Proxy types

HTTP and HTTPS proxies are supported. You can use either type in your application.

Proxy type

Description

HTTP proxy

Configure the proxy server address and port using the HttpProxy parameter. The format is http://<IP address>:<port>. This applies only to HTTP requests.

HTTPS proxy

Configure the proxy server address and port using the HttpsProxy parameter. The format is http://<IP address>:<port>.

Note

If the proxy server requires authentication, add the username and password to the address. The format is http://<user>:<password>@<IP address>:<port>.

Proxy configuration methods

Note

If both are set, the RuntimeOptions proxy configuration takes precedence over the client-level configuration.

  • Configure a proxy for a single request by using AlibabaCloud.TeaUtil.Models.RuntimeOptions.

    // Runtime parameter settings. These settings apply only to requests that use this RuntimeOptions instance.
    var runtimeOptions = new AlibabaCloud.TeaUtil.Models.RuntimeOptions
    {
        HttpProxy = "http://127.0.0.1:9898";
        HttpsProxy = "http://127.0.0.1:8989";
    };
    
  • Configure a proxy for all requests by using AlibabaCloud.OpenApiClient.Models.Config.

    var config = new AlibabaCloud.OpenApiClient.Models.Config
    {
        // Proxy parameter settings. These settings apply to all clients that use this config.
        HttpProxy = "http://127.0.0.1:9898",
        HttpsProxy = "http://127.0.0.1:8989"
    };
    

References

For the complete HTTP proxy setup, see HTTP proxy configuration.