{"id":535,"date":"2019-04-05T23:30:00","date_gmt":"2019-04-05T14:30:00","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/04\/05\/basic-auth-with-s3-and-cloudfront"},"modified":"2019-04-05T23:30:00","modified_gmt":"2019-04-05T14:30:00","slug":"basic-auth-with-s3-and-cloudfront","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/04\/05\/basic-auth-with-s3-and-cloudfront\/","title":{"rendered":"S3 + CloudFront\u306e\u9759\u7684\u30b5\u30a4\u30c8\u5185\u306e\u6240\u5b9a\u306e\u30d1\u30b9\u306b\u304a\u3044\u3066Basic\u8a8d\u8a3c\u3092\u5c0e\u5165\u3059\u308b"},"content":{"rendered":"

\u897f\u85e4\u3067\u3059\u3002<\/p>\n

\u9759\u7684\u306a\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u307f\u3067\u69cb\u6210\u3055\u308c\u308b\u30b5\u30a4\u30c8\u3092\u9ad8\u3044\u8010\u4e45\u6027\u3068\u9ad8\u901f\u306a\u30b3\u30f3\u30c6\u30f3\u30c4\u914d\u4fe1\u3059\u308b\u305f\u3081\u306b\u306f S3 + CloudFront<\/code> \u3068\u3044\u3046\u69cb\u6210\u306b\u3088\u308b\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u304c\u53ef\u80fd\u3067\u3059\u3002
\n\u3053\u308c\u306b\u3088\u308aEC2\u3067\u7acb\u3061\u4e0a\u3052\u308b\u30b5\u30fc\u30d0\u30fc\u306e\u7ba1\u7406\u304c\u4e0d\u8981\u306b\u306a\u308b\u306e\u3067\u3001\u3088\u308a\u5b89\u5fc3\u611f\u3092\u6301\u3063\u3066\u30b5\u30a4\u30c8\u904b\u7528\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u3055\u3089\u306b\u306f\u5f0a\u793e\u30d6\u30ed\u30b0\u306b\u304a\u3044\u3066\u3001
\nS3\u9759\u7684\u30a6\u30a7\u30d6\u30db\u30b9\u30c6\u30a3\u30f3\u30b0+CloudFront+Lambda@Edge\u3067Basic\u8a8d\u8a3c\u3092\u304b\u3051\u308b<\/a>
\n\u306e\u8a18\u4e8b\u306b\u3066\u3001\u305d\u306e\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3068\u305d\u306e\u30b5\u30a4\u30c8\u306bBasic\u8a8d\u8a3c\u3092\u304b\u3051\u308b\u65b9\u6cd5\u304c\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001<\/p>\n

\u4eca\u56de\u306f\u305d\u306eS3\u3068CloudFront\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u30db\u30b9\u30c8\u3055\u308c\u305f\u9759\u7684\u30b5\u30a4\u30c8\u306b\u304a\u3044\u3066\u3001\u300c\u7279\u5b9a\u306e\u30d1\u30b9\u306b\u304a\u3044\u3066Basic\u8a8d\u8a3c\u3092\u304b\u3051\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u3092\u5b9f\u73fe\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

\u3053\u308c\u306b\u3088\u308a\u300cID\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u77e5\u3063\u3066\u3044\u308b\u4eba\u3060\u3051\u304c\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u5c02\u7528\u30da\u30fc\u30b8\u300d\u3092\u30b5\u30a4\u30c8\u5185\u306e\u7279\u5b9a\u306e\u30d1\u30b9\u306b\u3066\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u69cb\u6210<\/h2>\n

\u307e\u305a\u4f5c\u308d\u3046\u3068\u3057\u3066\u3044\u308b\u30b5\u30a4\u30c8\u306e\u69cb\u6210\u3068\u3057\u307e\u3057\u3066\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

\"\"
\n\u3053\u308c\u3092 S3\u30d0\u30b1\u30c3\u30c8\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3001\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3092\u8a2d\u5b9a\u3001CloudFront\u7d4c\u7531\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n

\u305d\u3057\u3066\u3001\u4eca\u56de\u306f Directory_B\/<\/code> \u914d\u4e0b\u306b\u306e\u307f<\/strong>Basic\u8a8d\u8a3c\u3092\u9069\u7528\u3057\u3066\u3001\u300c\u7279\u5b9a\u306e\u30d1\u30b9\u306b\u304a\u3044\u3066Basic\u8a8d\u8a3c\u3092\u304b\u3051\u308b\u300d\u306e\u5b9f\u73fe\u3092\u76ee\u6307\u3057\u307e\u3059\u3002<\/p>\n

S3 + CloudFront \u3067\u306e\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u306e\u8868\u793a\u78ba\u8a8d<\/h2>\n

\u307e\u305a\u3001\u6700\u521d\u306bS3 + CloudFront \u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u308b\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002
\n\uff08S3 + CloudFront\u306e\u9759\u7684\u30b5\u30a4\u30c8\u69cb\u7bc9\u306e\u624b\u9806\u306f\u5272\u611b\u3044\u305f\u3057\u307e\u3059\uff09<\/p>\n

\"\"<\/p>\n

\u554f\u984c\u306a\u304f\u3001\u30b5\u30a4\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u76f4\u4e0b\u306e index.html\u3000\u304c\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3066\u30db\u30b9\u30c8\u3055\u308c\u305f\u30b5\u30a4\u30c8\u306e\u30da\u30fc\u30b8\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n

\u307e\u305f\u3001<\/p>\n

    \n
  • Directory_A<\/li>\n
  • Directory_B<\/li>\n<\/ul>\n

    \u305d\u308c\u305e\u308c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u7f6e\u304b\u308c\u3066\u3044\u308bindex.html\u3082\u540c\u69d8\u306b\u8868\u793a\u304c\u3067\u304d\u3066\u3044\u307e\u3059\u3002\uff08\u307e\u3060\u3001Basic\u8a8d\u8a3c\u306e\u8a2d\u5b9a\u3092\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u305d\u306e\u307e\u307e\u8868\u793a\u3055\u308c\u308b\uff09<\/p>\n

    \"\"<\/p>\n

    \"\"<\/p>\n

    CloudFront\u306eBehavior\u8a2d\u5b9a\u3092\u3059\u308b<\/h2>\n

    \u6b21\u306b\u5148\u307b\u3069\u306e\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3092\u3059\u308b\u305f\u3081\u306b\u8a2d\u5b9a\u3057\u305fCloudFront\u306b\u304a\u3044\u3066\u3001\u300c\u6240\u5b9a\u306e\u30d1\u30b9\uff08URL\uff09\u3054\u3068\u306b\u52d5\u4f5c\u3092\u6307\u5b9a\u3059\u308b\u300d\u305f\u3081\u306e\u8a2d\u5b9a Behavior<\/code> \u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002
    \n\u4eca\u56de\u306f\u3001<\/p>\n

      \n
    • Directory_A<\/li>\n
    • Directory_B<\/li>\n<\/ul>\n

      \u3067\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u3066\u3001\u305d\u308c\u305e\u308c\u7570\u306a\u308b\u52d5\u304d\u3092\u3055\u305b\u305f\u3044\u306e\u3067\u3001<\/p>\n

        \n
      • Directory_A\/*<\/code><\/li>\n
      • Directory_B\/*<\/code><\/li>\n<\/ul>\n

        \u306ePath Pattern\u306bBehavior\u8a2d\u5b9a\u3092\u3057\u307e\u3059\u3002<\/p>\n

        \"\"<\/p>\n

        \u5185\u5bb9\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n

        \"\"<\/p>\n

        \u3053\u308c\u3067A\u3068B\u305d\u308c\u305e\u308c\u306ePath Pattern<\/code>\u306eBehavior<\/code>\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n

        Basic\u8a8d\u8a3c\u7528\u306eLambda\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n

        \u6b21\u306b\u3001\u4e0a\u8a18\u306e\u8a18\u4e8b\u3092\u53c2\u8003\u306bCloudFront\u3078\u9069\u7528\u3059\u308bLambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002
        \n\u4eca\u56de\u306f Basic-Auth-test<\/code> \u3068\u3044\u3046\u540d\u524d\u306e\u95a2\u6570\u3092\u4f5c\u308b\u3082\u306e\u3068\u3057\u307e\u3059\u3002
        \n\uff08\u95a2\u6570\u306e\u5185\u5bb9\u30fb\u30ed\u30fc\u30eb\u306e\u8a2d\u5b9a\u306a\u3069\u306f\u5272\u611b\u3044\u305f\u3057\u307e\u3059\uff09<\/p>\n

        \"\"<\/p>\n

        Basic\u8a8d\u8a3c\u3092\u9069\u7528\u3057\u305f\u3044\u30d1\u30b9\u306b\u3060\u3051Lambda@edge\u3092\u9069\u7528\u3059\u308b<\/h2>\n

        \u305d\u3057\u3066\u3001\u4eca\u56de\u306e\u30dd\u30a4\u30f3\u30c8\u3068\u306a\u308b\u90e8\u5206\u3067\u3059\u3002
        \n\u95a2\u6570\u306e\u4f5c\u6210\u304c\u3067\u304d\u305f\u3089\u3001Lambda@edge\u306e\u30c7\u30d7\u30ed\u30a4\u3092\u884c\u3044\u307e\u3059\u304c\u3001\u8a2d\u5b9a\u306e\u969b\u306b \u30ad\u30e3\u30c3\u30b7\u30e5\u52d5\u4f5c<\/code> \u306e\u6b04\u3092\u9078\u629e\u3057\u307e\u3059\u3002
        \n\u3053\u3053\u3067\u51fa\u3066\u304f\u308b\u9078\u629e\u80a2\u304c\u5148\u307b\u3069\u3001CloudFront\u306eBehavior\u8a2d\u5b9a\u3067\u4f5c\u3063\u305fPath Pattern<\/code> \u3068\u5408\u81f4\u3057\u3066\u3044\u307e\u3059\u3002
        \n\u4eca\u56de\u3001Basic\u8a8d\u8a3c\u3092\u3064\u3051\u305f\u3044 Directory_B\/*<\/code> \u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n

        \"\"<\/p>\n

        \u3053\u308c\u3067Lambda@edge\u304cDirectory_B\/*<\/code>\u306e\u30d1\u30b9\u306b\u306e\u307f\u30c7\u30d7\u30ed\u30a4\u3055\u308c\u305f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

        CloudFront\u306eDirectory_B\/*<\/code>\u306ePath Pattern\u306eBehavior\u3092\u898b\u308b\u3068\u3001Lambda\u95a2\u6570\u304c\u95a2\u9023\u3065\u3051\u3089\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002
        \n\"\"<\/p>\n

        \u8868\u793a\u306e\u78ba\u8a8d<\/h2>\n

        \u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u518d\u3073\u30b5\u30a4\u30c8\u306e\u8868\u793a\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n

        \"\"<\/p>\n

        \u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306fBasic\u8a8d\u8a3c\u3082\u306a\u304f\u3001\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n

        \u6b21\u306b Directory_A\/<\/code> \u306e\u4e2d\u3092\u958b\u304d\u307e\u3059\u3002<\/p>\n

        \"\"<\/p>\n

        \u3053\u3061\u3089\u3082Basic\u8a8d\u8a3c\u304c\u51fa\u308b\u3053\u3068\u306a\u304f\u3001\u8868\u793a\u3055\u308c\u307e\u3059\u3001<\/p>\n

        \u305d\u3057\u3066\u3001\u6700\u5f8c\u306b Directory_B\/<\/code> \u306e\u4e2d\u3092\u958b\u304d\u307e\u3059\u3002<\/p>\n

        \"\"<\/p>\n

        \u3059\u308b\u3068\u3001Basic\u8a8d\u8a3c\u306e\u78ba\u8a8d\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u3001\u8a8d\u8a3c\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u306f<\/p>\n

        \"\"<\/p>\n

        \u3068\u5931\u6557\u306e\u8868\u793a\u306b\u306a\u308a\u307e\u3059\u3002
        \n\u6b63\u3057\u304f\u8a8d\u8a3c\u3055\u308c\u305f\u5834\u5408\u306f<\/p>\n

        \"\"<\/p>\n

        \u3068\u3044\u3046\u5177\u5408\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002
        \n\u3053\u308c\u3067\u3001\u7279\u5b9a\u306e\u30d1\u30b9\u306e\u307f\u3067Basic\u8a8d\u8a3c\u304c\u52d5\u4f5c\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n

        \u307e\u3068\u3081<\/h2>\n

        \u4ee5\u4e0a\u306e\u65b9\u6cd5\u306b\u3088\u308aS3 + CloudFront\u3067\u69cb\u6210\u3057\u3066\u3044\u308b\u9759\u7684\u30b5\u30a4\u30c8\u5185\u306b\u304a\u3044\u3066\u3001\u30d1\u30b9\u4f4d\u7f6e\u3092\u6307\u5b9a\u3057\u3066Basic\u8a8d\u8a3c\u3092\u8a2d\u7f6e\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002
        \nS3 + CloudFront\u306e\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3067\u306f\u306a\u304f\u3001\u305f\u3068\u3048\u3070EC2\u3067Apache\u30b5\u30fc\u30d0\u30fc\u306b\u3066\u540c\u69d8\u306e\u904b\u7528\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u6240\u5b9a\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4f4d\u7f6e\u306b .htpasswd<\/code> \u306e\u8a2d\u7f6e\u3092\u3057\u305f\u308a\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30b5\u30a4\u30ba\u306e\u9078\u5b9a\u3001\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306a\u3069\u306e\u904b\u7528\u9762\u306b\u3082\u6c17\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u5897\u3048\u3066\u304d\u307e\u3059\u3002
        \n\u52d5\u7684\u306a\u8981\u7d20\u3092\u542b\u307e\u306a\u3044\u9759\u7684\u306a\u30b5\u30a4\u30c8\u3067\u3001\u904b\u7528\u9762\u306e\u8ca0\u62c5\u3092\u3067\u304d\u308b\u3060\u3051\u5c0f\u3055\u3044\u5f62\u3067Basic\u8a8d\u8a3c\u3092\u5c0e\u5165\u3057\u305f\u3044\u3002\u3057\u304b\u3082\u30b5\u30a4\u30c8\u5185\u3067\u6240\u5b9a\u306e\u30d1\u30b9\u306e\u4e2d\u3067\u306e\u307f\u5c0e\u5165\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u6642\u306b\u3001\u4e0a\u8a18\u304c\u53c2\u8003\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

        \u897f\u85e4\u3067\u3059\u3002 \u9759\u7684\u306a\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u307f\u3067\u69cb\u6210\u3055\u308c\u308b\u30b5\u30a4\u30c8\u3092\u9ad8\u3044\u8010\u4e45\u6027\u3068\u9ad8\u901f\u306a\u30b3\u30f3\u30c6\u30f3\u30c4\u914d\u4fe1\u3059\u308b\u305f\u3081\u306b\u306f S3 + CloudFront \u3068\u3044\u3046\u69cb\u6210\u306b\u3088\u308b\u9759\u7684\u30b5\u30a4\u30c8\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u304c\u53ef\u80fd\u3067\u3059\u3002 \u3053\u308c\u306b\u3088\u308aEC2\u3067\u7acb\u3061\u4e0a\u3052\u308b\u30b5\u30fc\u30d0\u30fc\u306e\u7ba1\u7406\u304c\u4e0d\u8981\u306b\u306a\u308b\u306e\u3067\u3001\u3088\u308a\u5b89\u5fc3\u611f\u3092\u6301\u3063\u3066\u30b5\u30a4\u30c8\u904b\u7528\u304c\u3067\u304d\u307e\u3059\u3002 \u3055\u3089\u306b\u306f\u5f0a\u793e\u30d6\u30ed\u30b0\u306b\u304a\u3044\u3066\u3001 S3\u9759\u7684\u30a6\u30a7\u30d6\u30db\u30b9\u30c6\u30a3\u30f3\u30b0+CloudFront+Lambda@Edge\u3067Basic\u8a8d […]<\/p>\n","protected":false},"author":6,"featured_media":826,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,21],"tags":[321],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/535"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=535"}],"version-history":[{"count":0,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/535\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media\/826"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}