内容分发网络CDN

    访问控制

    设置访问 ip 控制

    def test_set_domain_ip_acl(self):
        """
        test_set_domain_ip_acl
        """
        error = None
        try:
            blackList = ['1.1.1.2', '1.1.1.3']
            response = self.cdn_client.set_domain_ip_acl(
                                domain = 'opencdn3.sys-qa.com',
                                blackList = blackList)
            print response
        except BceServerError as e:
            error = e
        finally:
            self.assertIsNone(error)

    查询访问 ip 控制

    def test_get_domain_ip_acl(c):
        """
        test get domain ip acl
        """
        response = c.get_domain_ip_acl('test-sdk.sys-qa.com')
        print(response)

    设置访问鉴权

        def test_set_request_auth(self):
            """
            test_set_request_auth
            """
            error = None
            try:
                request_auth = {
                    "type": "c",
                    "key1": "secretekey1",
                    "key2": "secretekey2",
                    "timeout": 300,
                    "whiteList": ["/crossdomain.xml"],
                    "signArg": "sign",
                    "timeArg": "t"
                }
                self.cdn_client.set_request_auth('opencdn3.sys-qa.com', request_auth)
            except BceServerError as e:
                error = e
            finally:
                self.assertIsNone(error)

    设置 cors 跨域

    def test_set_domain_cors(c):
        """
        test set domain cors
        """
        cors = {
                    "allow": "on",
                    "originList": ["http://www.baidu.com", "http://*.bce.com"]
                }
        domain = 'test-sdk.sys-qa.com'
        response = c.set_domain_cors(domain, cors);
        print(response)

    查询 cors 跨域

    def test_get_domain_cors(c):
        """
        test get domain cors
        """
        response = c.get_domain_cors('test-sdk.sys-qa.com')
        print(response)

    设置 ip 访问限频

    def test_set_domain_access_limit(c):
        """
        test set domain access limit
        """
        access_limit = {
                    "enabled": True,
                    "limit": 2000
                }
        domain = 'test-sdk.sys-qa.com'
        response = c.set_domain_access_limit(domain, access_limit);
        print(response)

    查询 ip 访问限频

    def test_get_domain_access_limit(c):
        """
        test get domain access limit
        """
        response = c.get_domain_access_limit('test-sdk.sys-qa.com')
        print(response)

    设置获取用户真实 ip

    def test_set_domain_client_ip(c):
        """
        test set domain client ip
        """
        client_ip = {
                    "enabled": True,
                    "name": "True-Client-Ip"
                }
        domain = 'test-sdk.sys-qa.com'
        response = c.set_domain_client_ip(domain, client_ip);
        print(response)

    查询获取用户真实ip

    def test_get_domain_client_ip(c):
        """
        test get domain client_ip
        """
        response = c.get_domain_client_ip('test-sdk.sys-qa.com')
        print(response)

    查询访问 Referer 控制

    def test_set_domain_referer_acl(c):
        """
        test_set_domain_referer_acl
        """
        blackList = ["http://a/b/c/", "http://c/d/e/"]
        response = c.set_domain_referer_acl(
                            domain = 'www.example.com',
                            blackList = blackList,
                            allowEmpty = True)
        print(response)
    上一篇
    回源配置
    下一篇
    HTTPS配置