Tüm Ürünler
Search
Belge Merkezi

Alibaba Cloud SDK:Proxy Yapılandırma

Son Güncelleme:Oct 07, 2026

Bu konuda, V1.0 SDK'da proxy'nin nasıl yapılandırılacağı açıklanmaktadır.

Proxy Türleri

HTTP ve HTTPS proxy'lerini kullanabilirsiniz. HTTP proxy'si HTTP istekleri için, HTTPS proxy'si ise HTTPS istekleri için kullanılır. Bir proxy yapılandırdıktan sonra, proxy erişimi gerektirmeyen belirli Alibaba Cloud ürünleri için SDK'yı proxy'yi atlayacak şekilde de ayarlayabilirsiniz.

Yapılandırma Yöntemleri

SDK, bir proxy'yi yapılandırmak için iki yöntem sunar:

  • Ortam değişkenlerini kullanın:

    • HTTP_PROXY veya http_proxy: HTTP proxy sunucusunun adresini belirtir.

    • HTTPS_PROXY: HTTPS proxy sunucusunun adresini belirtir.

    • NO_PROXY: Proxy'yi atlayacak adres listesini belirtir. Birden fazla adresi virgülle ayırın. Alan adları ve IP adresleri desteklenir.

  • Kodunuzda yapılandırın: Proxy'yi yapılandırmak için com.aliyuncs.http.HttpClientConfig sınıfını kullanın. Bu sınıf aşağıdaki yöntemleri sağlar:

    • setHttpProxy(): HTTP proxy sunucusunun adresini belirtir.

    • setHttpsProxy(): HTTPS proxy sunucusunun adresini belirtir.

    • setNoProxy(): Proxy'yi atlayacak adres listesini belirtir. Birden fazla adresi virgülle ayırın. Alan adları ve IP adresleri desteklenir.

    public static void main(String[] args) {
      com.aliyuncs.http.HttpClientConfig clientConfig = com.aliyuncs.http.HttpClientConfig.getDefault();
      // Set the HTTPS proxy. You must also set the ProtocolType.
      clientConfig.setHttpsProxy("http://user:password@127.0.0.1:8989");
      clientConfig.setProtocolType(com.aliyuncs.http.ProtocolType.HTTPS);
      
      // Set the HTTP proxy.
      clientConfig.setHttpProxy("http://127.0.0.1:9898");
    
      // Set the list of addresses to bypass the proxy.
      clientConfig.setNoProxy("ecs-cn-hangzhou.aliyuncs.com,dysmsapi.aliyuncs.com");
    
      com.aliyuncs.profile.DefaultProfile profile = com.aliyuncs.profile.DefaultProfile.getProfile(
        "<REGION_ID>",
        // Obtain the AccessKey ID of the RAM user from an environment variable.
        System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"),
        // Obtain the AccessKey secret of the RAM user from an environment variable.
        System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
      );
      profile.setHttpClientConfig(clientConfig);
      com.aliyuncs.IAcsClient client = new com.aliyuncs.DefaultAcsClient(profile);
      // The code for calling the API is omitted.      
    }

İlgili Konular

Daha fazla bilgi için bkz. HTTP Proxy Yapılandırma En İyi Uygulamaları.