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.
- 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.
- VPC/Classic network ECS: BucketName.region-internal.aliyuncs.com
- 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.
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.
For more information about the spelling rules and the Internet and intranet accessing rules for OSS, see Endpoints.
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.
When you configure an SDK to initialize the client, set the OSS intranet endpoint as the client endpoint. See Endpoints and Data Centers.
String endpoint = "http://oss-cn-hangzhou-internal.aliyuncs.com";//for example, East China 1
String accessKeyId = "<yourAccessKeyId>";
String accessKeySecret = "<yourAccessKeySecret>";
OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret);
For more information, see Java SDK.
$accessKeyId = "<the AccessKeyID you obtained from OSS>";
$accessKeySecret = "<the AccessKeySecret you obtained from OSS>";
$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.
auth = oss2.Auth ('your AccessKeyID', 'your AccessKeySecret')
endpoint = 'http://oss-cn-hangzhou-internal.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region
bucket = oss2.Bucket(auth, endpoint, 'your bucket name')
For more information, see Python SDK.
const string accessKeyId = "<your AccessKeyId>";
const string accessKeySecret = "<your AccessKeySecret>";
const string endpoint = "http://oss-cn-hangzhou-internal.aliyuncs.com";
var ossClient = new OssClient(endpoint, accessKeyId, accessKeySecret);
For more information, see .NET SDK.
ptions->config = oss_config_create(options->pool);
aos_str_set(&options->config->access_key_id, "<your AccessKeyId>");
aos_str_set(&options->config->access_key_secret, "<your AccessKeySecret>");
options->config->is_cname = 0;
options->ctl = aos_http_controller_create(options->pool, 0);
For more information, see C SDK.