edit-icon download-icon

How does ECS users use OSS intranet address properly?

Last Updated: Feb 07, 2018

If the ECS instance you purchased is in the same region as the OSS bucket, your ECS can access OSS over the intranet without incurring any traffic cost. Whether the access occurs over the intranet depends on the domain name you configured. If the domain name you configured is the domain name of the intranet, the access occurs over the intranet. If the domain name you configured is not the domain name of the intranet, the access occurs over the Internet.

Note:

  • ECS in the same region can access OSS over the intranet.
  • ECS and OSS of different accounts can communicate with each other over the intranet.
  • ECS in a different region cannot access OSS over the intranet.

Intranet address format

  • VPC/Classic network ECS: BucketName.region-internal.aliyuncs.com

Example:

  • East China 2 VPC/classic network ECS: aliyun-abc.oss-cn-shanghai-internal.aliyuncs.com

See the table in Regions and endpoints for available regions.

Quickly obtain the intranet address of the bucket in the console

Log on to the OSS console, and select the bucket to open the Overview page of the bucket. The bucket address is displayed in the Access Domain Name area.

Rules of using OSS access domain names

For more information about the spelling rules and the Internet and intranet accessing rules for OSS, see Endpoints.

How a website uses OSS resources over the intranet

If a website is deployed on ECS, directly embed the intranet URL of the object, for example, http://ali.oss-cn-hangzhou-internal.aliyuncs.com/1.jpg, for the customers to access. Customers who directly access the OSS intranet address by the webpage on their local PC, or an Internet environment, cannot obtain the object.

If a website on ECS in the same region calls OSS resources over the intranet, you must set the access link of the webpage as ECS resources. ECS obtains OSS resources over the intranet for the customers to access. How to obtain: API/SDK or reverse proxy. ECS bandwidth may become a bottleneck when the website is visited heavily.

How an SDK/API uses OSS over the intranet

When you configure an SDK to initialize the client, set the OSS intranet endpoint as the client endpoint. See Endpoints and Data Centers.

Java

  1. String endpoint = "http://oss-cn-hangzhou-internal.aliyuncs.com";//for example, East China 1
  2. String accessKeyId = "<yourAccessKeyId>";
  3. String accessKeySecret = "<yourAccessKeySecret>";
  4. OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret);

For more information, see Java SDK.

PHP

  1. $accessKeyId = "<the AccessKeyID you obtained from OSS>";
  2. $accessKeySecret = "<the AccessKeySecret you obtained from OSS>";
  3. $endpoint = "<The endpoint of the OSS data center you selected, for example, http://oss-cn-hangzhou-internal.aliyuncs.com>";

For more information, see PHP SDK.

Python

  1. auth = oss2.Auth ('your AccessKeyID', 'your AccessKeySecret')
  2. endpoint = 'http://oss-cn-hangzhou-internal.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region
  3. bucket = oss2.Bucket(auth, endpoint, 'your bucket name')

For more information, see Python SDK.

.Net

  1. const string accessKeyId = "<your AccessKeyId>";
  2. const string accessKeySecret = "<your AccessKeySecret>";
  3. const string endpoint = "http://oss-cn-hangzhou-internal.aliyuncs.com";
  4. var ossClient = new OssClient(endpoint, accessKeyId, accessKeySecret);

For more information, see .NET SDK.

C

  1. ptions->config = oss_config_create(options->pool);
  2. aos_str_set(&options->config->endpoint, "http://oss-cn-hangzhou-internal.aliyuncs.com");
  3. aos_str_set(&options->config->access_key_id, "<your AccessKeyId>");
  4. aos_str_set(&options->config->access_key_secret, "<your AccessKeySecret>");
  5. options->config->is_cname = 0;
  6. options->ctl = aos_http_controller_create(options->pool, 0);

For more information, see C SDK.

Thank you! We've received your feedback.