How to apply the intranet address of OSS

Keywords: network SDK VPC PHP

1. How to apply the intranet address of OSS in each network environment
Only ECS in the same region can link OSS to the intranet, and cross-account ECS and OSS can also connect to the intranet.ECS is divided into classic network ECS and VPC network ECS,**classic network ECS calls OSS classic network intranet address to link OSS**:bucketname.intranet Endpoint, the format of Intranet endpoint is;**VPC network ECS calls OSSVPC intranet address to connect OSS to intranet**:bucketname.VPC network Endpoint, VPC network endpoint format is generally; where region can be oss-cn-hangzhou, oss-cn-beijing, oss-cn-shanghai, oss-cn-shenzhen, and so on; OSS different regions and different network environments (external network/VPC/classical network) have different endpoints, OSS opens the Region and Endpoint control table reference: OSS Open Region and Endpoint Table

How to get the address of the OSS:
1) The endpoints of OSS corresponding network environment in corresponding regions can be obtained through OSS open Region and Endpoint comparison tables, which are stitched together by bucketname.endpoint;
2) The console obtains the address of the bucket;
Ali Cloud Console - OSS - Select specific bucket - The address of the bucket is shown in the overview

2. How to Apply OSS Resources on the Intranet in Site
There are intranet URL s where customers apply object s directly on the site page, such as , abnormal site access, because the customer's user opened the site on their local PC, which is equivalent to the local PC directly requesting the OSS's intranet, while the OSS's Intranet can only be accessed by the ECS in the same area. If the customer's local PC is in a non-ECS network environment, the network will not be reachable and access abnormal; if the customer wants to apply OSS resources directly in the site's Intranet

How to apply OSS resources within your site's intranet:
The customer's site must be deployed on an ECS in the same area as the OSS, as described below
1) The Web side initiates a request to the ECS, ECS parses the request, object name and bucket name to be accessed by the web side, SDK or API for integration of OSS by ECS, calls SDK or API to get OSS resources, and returns them to the web side;
OSS SDK Reference: OSS SDK
API Operations Reference: OSS API operations

2) The Web side initiates a request for the URL under a directory of the site, which sets up a reverse proxy to proxy to the OSS intranet;
The site server ECS receives requests, the intranet requests OSS resources, and returns data to the Web side.
Reverse proxy configuration: The site domain name binds a bucket, but does not require cname resolution to the bucket's network address;
Site directory configuration Reverse proxy configuration, proxy to OSS intranet address
The Nginx reverse proxy configuration is similar to the following

server {
listen       80 ; #default_server;
location / {
root /alidata/www/ www-a-com/;

Bucket binding domain name to see: Custom domain name binding

3. How SDK Apply OSS Resources in Intranet
When the SDK initializes the client, the endpoint passes in the OSS intranet address. The OSS intranet address can be obtained to see How OSS intranet address is applied in each network environment.

String endpoint = "";
// Cloud account AccessKey has all API access rights. It is recommended that you follow Ali Cloud Security Best Practices to create and use RAM subaccounts for API access or daily maintenance. Please log in to to create
String accessKeyId = "<yourAccessKeyId>";
String accessKeySecret = "<yourAccessKeySecret>";
// Create an OSSClient instance
OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret);

Reference resources: Javasdk Initialization client

$accessKeyId = "<You are from OSS Acquired AccessKeyId>";
$accessKeySecret = "<You are from OSS Acquired AccessKeySecret>";
$endpoint = "<The one you selected OSS Data center accesses domain names, such as>";
try {
    $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
} catch (OssException $e) {
    print $e->getMessage();

Reference resources: PHP SDK Initialization client


auth = oss2.Auth('Your AccessKeyId', 'Your AccessKeySecret')
endpoint = ''#Suppose Bucket is in the Hangzhou area
bucket = oss2.Bucket(auth, endpoint, 'Your Bucket name')
**4)Net sdk**
const string accessKeyId = "<your AccessKeyId>";
const string accessKeySecret = "<your AccessKeySecret>";
const string endpoint = "";
var ossClient = new OssClient(endpoint, accessKeyId, accessKeySecret);

Reference resources: Python SDK Initialization client
**5)C **

    options->config = oss_config_create(options->pool);
    aos_str_set(&options->config->endpoint, "");
    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);

Reference resources: C SDK Initialization client

Posted by zyrolasting on Wed, 29 May 2019 11:10:03 -0700