{"id":1761,"date":"2022-04-05T17:13:24","date_gmt":"2022-04-05T09:13:24","guid":{"rendered":"https:\/\/www.chenqing.work\/?p=1761"},"modified":"2022-04-06T11:50:44","modified_gmt":"2022-04-06T03:50:44","slug":"%e6%b5%8f%e8%a7%88%e5%99%a8%e4%bd%bf%e7%94%a8%e5%b0%8f%e8%ae%b0-csp","status":"publish","type":"post","link":"https:\/\/www.chenqing.work\/?p=1761","title":{"rendered":"\u6d4f\u89c8\u5668\u4f7f\u7528\u5c0f\u8bb0 &#8211; Content-Security-Policy"},"content":{"rendered":"\n<p>\u6700\u8fd1\u91cd\u5ea6\u4f7f\u7528\u7f51\u5173 Kong\uff0c\u5bf9\u63a5\u4e86\u4e00\u5806\u96be\u641e\u7684\u5b58\u91cf\u7cfb\u7edf\uff0c\u9047\u5230\u5f88\u591a\u95ee\u9898\uff0c\u5148\u6254\u4e00\u4e2a\uff1a\u5f53 Kong \u8f6c\u53d1\u8bf7\u6c42\u540e\uff0c\u7b2c\u4e09\u65b9\u7684\u54cd\u5e94\u5185\u5bb9\u91cc\u62fc\u63a5\u4e86\u5b8c\u6574\u7684\u8d44\u6e90\u8bf7\u6c42\u5730\u5740\uff0c\u4f46\u5b83\u770b\u5230\u7684\u53ea\u662f Kong \u5265\u6389 https \u58f3\u4ee5\u540e\u7684 http \u8bf7\u6c42\uff0c\u6240\u4ee5\u62fc\u63a5\u51fa\u6765\u7684\u5730\u5740\u662f http:\/\/&#8230;. \uff0c\u5230\u4e86\u6d4f\u89c8\u5668\u7aef\uff0c\u6839\u636e\u8be5\u5730\u5740\u53d1\u8d77 http \u8bf7\u6c42\u65f6\uff0c\u5c31\u4f1a\u88ab\u6d4f\u89c8\u5668 block \u6389\uff0c\u5f00 debug \u53ef\u4ee5\u770b\u5230\u63d0\u793a csp \u6216\u8005 mixed\u3002<\/p>\n\n\n\n<p>\u5728\u6709\u591a\u4e2a\u7ec4\u6210\u73af\u8282\u7684\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u95ee\u9898\u901a\u5e38\u5c31\u4f1a\u6709\u591a\u79cd\u89e3\u6cd5\uff08\u7529\u9505\u5e94\u8be5\u66f4\u5f62\u8c61\uff09\u3002\u5c31\u76ee\u524d\u8fd9\u4e2a\u95ee\u9898\uff0c\u6de1\u5316 PaaS\/CaaS \u7b49\u8bbe\u65bd\u7684\u60c5\u51b5\u4e0b\uff0c\u53c2\u4e0e\u73af\u8282\u53ef\u4ee5\u805a\u7126\u5230\u4e09\u4e2a\uff1a\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668 &#8212; Kong \u7f51\u5173 &#8212; \u5b58\u91cfX\u7cfb\u7edf\u3002<\/p>\n\n\n\n<p>\u6700\u76f4\u63a5\u7684\u60f3\u6cd5\u5c31\u662f\u7531 X \u7cfb\u7edf\u81ea\u884c\u8c03\u6574\uff0c\u4ece\u5c3d\u91cf\u51cf\u5c11\u8026\u5408\u7684\u89d2\u5ea6\u6765\u8bf4\uff0c\u4e00\u4e2a\u7cfb\u7edf\u5e94\u8be5\u5c3d\u91cf\u4e0d\u4e86\u89e3\u5176\u4ed6\u7cfb\u7edf\u7684\u77e5\u8bc6\uff0c\u4e0d\u5e94\u8be5\u62fc\u63a5\u5b8c\u6574\u7684 url \u8bf7\u6c42\u5730\u5740\uff0c\u6700\u597d\u662f\u80fd\u6839\u636e rfc7231 \u91cc\u7684\u63cf\u8ff0\u6539\u7528 relative url absolute path\uff0c\u5b8c\u6574\u7684\u8bf7\u6c42\u5730\u5740\u5219\u4ea4\u7531\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u53bb\u62fc\u63a5\u3002<\/p>\n\n\n\n<p>\u7136\u9e45\u5b58\u7eed\u65f6\u95f4\u6bd4\u8f83\u957f\u7684\u4f01\u4e1a\u91cc\uff0c\u5386\u53f2\u79ef\u7d2f\u4e0b\u6765\u7684\u5404\u79cd\u5b58\u91cf\u7cfb\u7edf\u60c5\u51b5\u4e00\u822c\u90fd\u6bd4\u8f83\u590d\u6742\uff0c\u5b58\u91cf X \u7cfb\u7edf\u65e0\u529b\u8c03\u6574\u3002\u79c9\u7740\u7f51\u5173\u5c3d\u91cf\u900f\u660e\u7684\u539f\u5219\uff0c\u5206\u6790\u5904\u7406\u4e4b\u3002<\/p>\n\n\n\n<p>\u56de\u5230\u6700\u5f00\u59cb\u6d4f\u89c8\u5668\u63d0\u793a\u7684 CSP \u95ee\u9898\uff0cCSP \u5373 Content-Security-Policy\uff0c\u56e0\u4e3a\u6211\u4eec\u7684\u7f51\u7ad9\u5728\u6d4f\u89c8\u5668\u7aef\u662f\u901a\u8fc7 https \u8bbf\u95ee\u7684\uff0c\u4ece\u4e00\u4e2a https \u7684\u7f51\u9875\u4e0a\u53d1\u8d77 http \u8bf7\u6c42\uff0c\u5c5e\u4e8e\u5b89\u5168\u6027\u964d\u7ea7\u7684\u64cd\u4f5c\uff0c\u88ab\u8ba4\u4e3a\u662f\u4e0d\u5b89\u5168\u7684\uff0c\u6240\u4ee5\u6d4f\u89c8\u5668\u76f4\u63a5 block \u6389\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\u8fd9\u79cd\u60c5\u5f62\u5b9e\u9645\u4e0a\u5e76\u4e0d\u5c11\u89c1\uff0c\u6bd4\u5982\u6211\u7684\u7f51\u7ad9\u4ee5\u524d\u53bb\u7b2c\u4e09\u65b9\u8bf7\u6c42\u4e86\u4e00\u4e9b\u8d44\u6e90\uff0c\u5f53\u65f6\u5927\u5bb6\u90fd\u662f http\uff0c\u6ca1\u5565\u95ee\u9898\uff0c\u540e\u6765\u6211\u4e00\u591c\u4e4b\u95f4\u5347\u7ea7\u5230 https \u540e\uff0c\u56e0\u4e3a\u6d4f\u89c8\u5668\u5b89\u5168\u7b56\u7565\u53ef\u80fd\u5c31\u52a0\u8f7d\u4e0d\u5230\u8fd9\u4e9b\u8d44\u6e90\u4e86\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e0b\u548b\u529e\uff1f\u6807\u51c6\u91cc\u6253\u4e86\u4e00\u4e2a<a href=\"https:\/\/w3c.github.io\/webappsec-upgrade-insecure-requests\/#delivery\" data-type=\"URL\" data-id=\"https:\/\/w3c.github.io\/webappsec-upgrade-insecure-requests\/#delivery\">\u8865\u4e01<\/a>\uff0c\u5141\u8bb8\u901a\u8fc7\u8bbe\u7f6e upgrade-insecure-requests\uff08\u5b57\u9762\u610f\u601d\uff1a\u5347\u7ea7\u4e0d\u5b89\u5168\u7684\u8bf7\u6c42\uff09\uff0c\u544a\u77e5\u6d4f\u89c8\u5668\u81ea\u52a8\u5c06 http \u7684\u8bf7\u6c42\u66ff\u6362\u4e3a https \u7684\u8bf7\u6c42\u3002<\/p>\n\n\n\n<p>\u6309\u8fd9\u4e2a\u601d\u8def\uff0c\u5728\u8fd4\u56de\u7684\u7b2c\u4e00\u4e2a\u54cd\u5e94\u7ecf\u8fc7 Kong \u65f6\uff0c\u8bbe\u7f6e\u4e0a\u5934\u90e8\u3010content-security-policy: upgrade-insecure-requests\u3011\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<p>\u5f53\u7136\u8fd9\u4e5f\u53ea\u662f\u4e00\u79cd\u4ece http \u8f6c\u5411 https \u7684\u8fc7\u6e21\u63aa\u65bd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u91cd\u5ea6\u4f7f\u7528\u7f51\u5173 Kong\uff0c\u5bf9\u63a5\u4e86\u4e00\u5806\u96be\u641e\u7684\u5b58\u91cf\u7cfb\u7edf\uff0c\u9047\u5230\u5f88\u591a\u95ee\u9898\uff0c\u5148\u6254\u4e00\u4e2a\uff1a\u5f53 Kong \u8f6c\u53d1\u8bf7\u6c42 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[65,64,66],"class_list":["post-1761","post","type-post","status-publish","format-standard","hentry","category-code","tag-csp","tag-kong","tag-upgrade-insecure-requests"],"_links":{"self":[{"href":"https:\/\/www.chenqing.work\/index.php?rest_route=\/wp\/v2\/posts\/1761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chenqing.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chenqing.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chenqing.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chenqing.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1761"}],"version-history":[{"count":8,"href":"https:\/\/www.chenqing.work\/index.php?rest_route=\/wp\/v2\/posts\/1761\/revisions"}],"predecessor-version":[{"id":1772,"href":"https:\/\/www.chenqing.work\/index.php?rest_route=\/wp\/v2\/posts\/1761\/revisions\/1772"}],"wp:attachment":[{"href":"https:\/\/www.chenqing.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chenqing.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chenqing.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}