All Products
Search
Document Center

Alibaba Cloud SDK:Configure a proxy

Last Updated:Mar 04, 2025

This topic describes how to configure a proxy in the Classic SDK.

You can use the following environment variables to configure an HTTP proxy, an HTTPS proxy, and the addresses that do not require proxies:

  • HTTP_PROXY or http_proxy

  • HTTPS_PROXY

  • NO_PROXY

You can also configure a proxy when you initialize an SDK client.

//The proxy that you configure when you initialize the SDK client takes precedence over the proxy that you configure by using the environment variables.

//Configure an HTTP proxy.
client.SetHttpProxy("http://localhost:8080");
//Query the HTTP proxy.
client.GetHttpProxy();

//Configure an HTTPS proxy.
client.SetHttpsProxy("https://localhost:8080");
client.SetHttpsProxy("http://username:password@localhost:8080");
//Query the HTTPS proxy.
client.GetHttpsProxy();

// Configure the addresses that do not require proxies.
client.SetNoProxy("example.com");
// Query the addresses that do not require proxies.
client.GetNoProxy();