设置Bucket镜像源
Last updated
2023-07-14 09:45:25
{"value":"## **\u63cf\u8ff0**\n\n\u955c\u50cf\u5b58\u50a8\u670d\u52a1\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u5b9e\u73b0\u6570\u636e\u70ed\u8fc1\u79fb\uff0c\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u5e76\u4e0d\u5f71\u54cd\u539f\u6709\u4e1a\u52a1\u7cfb\u7edf\u7684\u8bbf\u95ee\u3002\u955c\u50cf\u5b58\u50a8\u9002\u7528\u4e8e\u8fc1\u79fb\u539f\u6709\u4e1a\u52a1\u7cfb\u7edf\u7684\u5df2\u6709\u6570\u636e\u3002\n\n\n\n## **\u8bf7\u6c42**\n\n\n\n**\u8bed\u6cd5**\n\n```\nPOST \/mirrorConfig\/set HTTP\/1.1\nHost: uc-qos.pocdemo.qiniu.io\nContent-Type: application\/json\nAuthorization: Qiniu <AccessToken>\n\n{\n \"bucket\":<Bucket>,\n \"host\":<Host>,\n \"source_retry_codes\":[<SourceRetryCode1>,<SourceRetryCode2>],\n \"source_qiniu_ak\":<SourceQiniuAK>,\n \"source_qiniu_sk\":<SourceQiniuSK>,\n \"expires\":<Expires>,\n \"sources\":[\n {\n \"addr\":<Addr1>, \n \"weight\":<Weight>,\n \"backup\":<Backup> \n },\n {\n \"addr\":<Addr2>,\n \"weight\":<Weight>,\n \"backup\":<Backup>\n }\n ],\n \"imgsft\": <0|1>,\n \"source_headers\": {\n \"header1\": \"value1\",\n \"header2\": \"value2\"\n },\n \"mirror_raw_query_option\": false, \n \"mirror_check_headers\": [header1, header2],\n \"source_fail_cache\": {\n \"<Code1>\":<Second1>,\n \"<Code2>\":<Second2>\n },\n \"source_fail_refresh_cdn\": false, \n \"source_mode\":<0|1|2>,\n \"fragment_opt\":{\n \"fragment_size\":<FragmentSize>,\n \"ignore_etag_check\":<IgnoreEtagCheck>\n }\n}\n```\n\n\u4f7f\u7528\u8bf4\u660e\uff1a\n\n- \u53d6\u56de\u52a8\u4f5c\u4ec5\u5728\u7b2c\u4e00\u6b21\u8bbf\u95ee\u8d44\u6e90\u4e0d\u5b58\u5728\u65f6\u53d1\u751f\n- \u53d6\u56de\u52a8\u4f5c\u662f\u4e00\u4e2a\u540c\u6b65\u64cd\u4f5c\uff0c\u6e90\u6587\u4ef6\u8fc7\u5927\u53ef\u80fd\u5bfc\u81f4\u5ba2\u6237\u7aef\u7b49\u5f85\u8d85\u65f6\n- \u53d6\u56de\u52a8\u4f5c\u5931\u8d25\u65f6\uff0c\u4f1a\u8fd4\u56de HTTP \u54cd\u5e94\u7801\n- \u6e90\u7ad9\u540c\u540d\u8d44\u6e90\u7684\u5185\u5bb9\u53d1\u751f\u6539\u53d8\u540e\uff0c\u79c1\u6709\u4e91\u5b58\u50a8\u4e0d\u4f1a\u81ea\u52a8\u5c06\u65b0\u5185\u5bb9\u53d6\u56de\uff0c\u7528\u6237\u9700\u8981\u5220\u9664\u7a7a\u95f4\u4e2d\u7684\u8d44\u6e90\uff0c\u518d\u5237\u65b0\u9884\u53d6\u624d\u53ef\u4ee5\u8bbf\u95ee\u5230\u66f4\u65b0\u540e\u7684\u8d44\u6e90\n- \u591a\u4e2a\u5ba2\u6237\u7aef\u89e6\u53d1\u955c\u50cf\u56de\u6e90\u65f6\uff0c\u8d44\u6e90\u7684\u6700\u7ec8\u5185\u5bb9\u4e3a\u6700\u540e\u4e00\u4e2a\u6210\u529f\u6267\u884c\u7684\u64cd\u4f5c\u6240\u5b58\u50a8\u7684\u7ed3\u679c\n\n\n\n**\u8bf7\u6c42\u5934**\n\n\u8be5\u8bf7\u6c42\u64cd\u4f5c\u7684\u5b9e\u73b0\u4f7f\u7528\u4e86\u6240\u6709\u64cd\u4f5c\u7684\u516c\u5171\u8bf7\u6c42\u5934\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u67e5\u9605[\u516c\u5171\u8bf7\u6c42\u5934](https:\/\/portal.7oss-hk.cdncloud.com\/doc\/kodo\/api\/3924\/common-request-headers.html)\u3002\n\n\n\n**\u8bf7\u6c42\u5143\u7d20**\n\n\u8be5\u8bf7\u6c42\u64cd\u4f5c\u7684\u8bf7\u6c42\u4f53\u4e3a\u5982\u4e0b\u8868\u6240\u793a\uff1a\n\n| \u53c2\u6570\u540d\u79f0 | \u5fc5\u586b | \u8bf4\u660e |\n| ----------------------------- | ---- | ------------------------------------------------------------ |\n| Bucket | \u662f | \u7a7a\u95f4\u540d |\n| Host | \u5426 | \u56de\u6e90Host |\n| RetryCodes | \u5426 | \u955c\u50cf\u56de\u6e90\u65f6\u6e90\u7ad9\u8fd4\u56deCode\u53ef\u4ee5\u91cd\u8bd5\uff0c\u6700\u591a\u6307\u5b9a3\u4e2a\uff0c\u5f53\u524d\u53ea\u652f\u63014xx\u9519\u8bef\u7801\u91cd\u8bd5 |\n| SourceQiniuAK,SourceQiniuSK | \u5426 | \u5982\u679c\u5b58\u5728\u5c06\u5728\u56de\u6e90\u65f6\u5bf9URL\u8fdb\u884c\u7b7e\u540d\uff0c\u5ba2\u6237\u6e90\u7ad9\u53ef\u4ee5\u9a8c\u8bc1\u4ee5\u4fdd\u8bc1\u8bf7\u6c42\u6765\u81eaQiniu\u670d\u52a1\u5668 |\n| Expires | \u5426 | \u7b7e\u540d\u8fc7\u671f\u65f6\u95f4\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\u9ed8\u8ba4\u4e3a1\u5c0f\u65f6 |\n| Addr | \u5426 | \u56de\u6e90\u5730\u5740\uff0c\u4e0d\u53ef\u91cd |\n| Weight | \u5426 | \u6743\u91cd,\u8303\u56f4\u9650\u52361-100,\u4e0d\u586b\u9ed8\u8ba4\u4e3a1,\u56de\u6e90\u65f6\u4f1a\u6839\u636e\u6240\u6709\u6e90\u7684\u6743\u91cd\u503c\u8fdb\u884c\u6e90\u7ad9\u9009\u62e9,\u4e3b\u5907\u6e90\u4f1a\u5206\u5f00\u8ba1\u7b97 |\n| Backup | \u5426 | \u662f\u5426\u5907\u7528\u56de\u6e90,\u56de\u6e90\u4f18\u5148\u5c1d\u8bd5\u4e3b\u6e90\uff0c\u5f53\u524d\u6700\u591a\u652f\u6301\u8bbe\u7f6e10\u4e2a\u4e3b\u6e90+10\u4e2a\u5907\u6e90 |\n| imgSFT | \u5426 | \u56de\u6e90\u5bb9\u9519\u5c5e\u6027\uff1b0-\u5173\u95ed\u5bb9\u9519 \uff0c1-\u5f00\u542f\u5bb9\u9519 |\n| source_headers\u7684Header | \u5426 | \u6e90\u7ad9\u8fd4\u56de\u7684Header(\u5927\u5c0f\u5199\u4e0d\u533a\u5206)\uff0c\u4e0d\u80fd\u5305\u542b'\/'\u5b57\u7b26 |\n| source_headers\u7684Value | \u5426 | \u4e0b\u8f7d\u65f6\u8fd4\u56de\u7ed9\u5ba2\u6237\u7684Header(\u5927\u5c0f\u5199\u4e0d\u533a\u5206\uff0c\u8fd4\u56de\u65f6\u5c06\u4f1a\u6807\u51c6\u5316) |\n| mirror_raw_query_option | \u662f | \u652f\u6301\u5e26\u95ee\u53f7\u56de\u6e90\uff1btrue-\u652f\u6301\uff0cfalse-\u4e0d\u652f\u6301\uff1b\u4e0d\u8bbe\u7f6e\u9ed8\u8ba4\u4e3afalse |\n| mirror_check_headers\u7684header1 | \u5426 | \u955c\u50cf\u56de\u6e90\u5fc5\u987b\u68c0\u67e5\u5b58\u5728\u7684header |\n| Code | \u5426 | \u9700\u8981\u7f13\u5b58\u7684\u9519\u8bef\u7801\uff0c\u652f\u63014xx,5xx\u9519\u8bef\u7801 |\n| Second | \u5426 | \u7f13\u5b58\u65f6\u95f4\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u5982\u8bbe\u4e3a0\u5c06\u4f7f\u7528\u670d\u52a1\u7aef\u9ed8\u8ba4\u914d\u7f6e |\n| source_fail_refresh_cdn | \u5426 | \u56de\u6e90\u5931\u8d25\u5237\u65b0Cdn\uff1btrue-\u5237\u65b0\uff0cfalse-\u4e0d\u5237\u65b0\uff1b\u4e0d\u8bbe\u7f6e\u9ed8\u8ba4\u4e3afalse |\n| source_mode | \u662f | \u56de\u6e90\u6a21\u5f0f\uff0c0-\u666e\u901a\u56de\u6e90(\u59cb\u7ec8\u4ee5\u5b8c\u6574\u6587\u4ef6\u8bf7\u6c42\u56de\u6e90\u6e90\u7ad9\u5e76\u4e0a\u4f20\u5b58\u50a8) 1-Range\u900f\u4f20\u56de\u6e90(\u5982\u679cIO\u6536\u5230Range\u8bf7\u6c42\uff0c\u56de\u6e90\u65f6\u4f18\u5148\u5e26\u4e0aRange\u56de\u6e90\u6e90\u7ad9\uff0c\u518d\u5f02\u6b65\u56de\u6e90\u5b8c\u6574\u6587\u4ef6\u4e0a\u4f20\u5b58\u50a8) 2-\u5206\u7247\u56de\u6e90(\u65e0\u8bbaIO\u6536\u5230Range\u6216\u975eRange\u8bf7\u6c42,\u59cb\u7ec8\u4ee5\u7279\u5b9a\u5206\u7247\u5927\u5c0f\u5411\u6e90\u7ad9\u53d1\u9001\u8bf7\u6c42\u5e76\u7f13\u5b58\u4e0a\u4f20\u5b58\u50a8) |\n| FragmentOpt | \u5426 | \u4ec5\u5f53Mode=2\u65f6\u6b64\u9879\u624d\u751f\u6548 |\n| FragmentSize | \u5426 | \u5206\u7247\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3a\u5b57\u8282\uff0c\u5f53\u524d\u652f\u6301\u8bbe\u7f6e1MB\/4MB |\n| IgnoreEtagCheck | \u5426 | \u5206\u7247\u65f6\u662f\u5426\u5ffd\u7565Etag\u6821\u9a8c\uff0c\u9ed8\u8ba4\u503c\u4e3afalse\u3001\u4f7f\u7528\u6821\u9a8c |\n\n\n\n## **\u54cd\u5e94**\n\n\n\n**\u54cd\u5e94\u5934**\n\n\u8be5\u8bf7\u6c42\u64cd\u4f5c\u7684\u5b9e\u73b0\u4f7f\u7528\u4e86\u6240\u6709\u64cd\u4f5c\u7684\u516c\u5171\u8bf7\u6c42\u5934\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u67e5\u9605\u516c\u5171\u54cd\u5e94\u5934\u3002\n\n\n\n**\u54cd\u5e94\u5143\u7d20**\n\n\u8be5\u8bf7\u6c42\u64cd\u4f5c\u7684\u54cd\u5e94\u4f53\u4e3a\u7a7a\u3002\n\n\n\n**\u7279\u6b8a\u9519\u8bef**\n\n\u8be5\u64cd\u4f5c\u7684\u5b9e\u73b0\u4e0d\u4f1a\u8fd4\u56de\u7279\u6b8a\u9519\u8bef\u3002\u6709\u5173\u9519\u8bef\u548c\u9519\u8bef\u4ee3\u7801\u5217\u8868\u7684\u4e00\u822c\u4fe1\u606f\uff0c\u8bf7\u67e5\u9605\u9519\u8bef\u54cd\u5e94\u3002\n\n\n\n## **\u793a\u4f8b**\n\n\n\n**\u8bf7\u6c42\u793a\u4f8b**\n\n```\nPOST \/mirrorConfig\/set HTTP\/1.1\nHost: uc-qos.pocdemo.qiniu.io\nUser-Agent: Go-http-client\/1.1\nAuthorization: QBox w6PQLatuvjv16mdiRGhTyxPBVeYuoRAI3FVnHAJgAAivlj5gwKV0QWuuB6eEJdNILe_U3FB-WCR-aZSxQsdoJv0wWPdrVZAY6JylIv00iiczsd2vzq2sFykXG_X32yZhw==\nAccept-Encoding: gzip\n\n{ \n \"bucket\":\"MyTest\", \n \"host\":\"baidu.com\", \n \"sources\":[ \n { \n \"addr\":\"127.0.0.1:4000\", \n \"weight\":100, \n \"backup\":false \n }], \n \"mirror_raw_query_option\": false, \n \"source_fail_refresh_cdn\": false, \n \"source_mode\":2, \n \"fragment_opt\":{ \n \"fragment_size\":4194304, \n \"ignore_etag_check\":true \n } \n}\n```\n\n\n\n**\u54cd\u5e94\u793a\u4f8b**\n\n```\nHTTP\/1.1 200 OK \nContent-Length\uff1a2 \nContent-Type\uff1aapplication\/json \nX-Log\uff1aBUCKET;BUCKET:29 \nX-Reqid\uff1aFE4AAJNDtWmTzHsV \nDate\uff1aMon, 21 Jan 2019 07:30:30 GMT\n```\n"}