AWS CloudFront access denied to S3 bucket

前端 未结 6 477
一向
一向 2021-01-31 07:34

I am trying to setup CloudFront to serve static files hosted in my S3 bucket. I have setup distribution but I get AccessDenied when trying

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 08:16

    In my case I was using multiple origins with "Path Pattern" Behaviors along with an Origin Path in my S3 bucket:

    Bad setup:

    CloudFront Behavior: /images/* -> My-S3-origin

    My-S3-origin: Origin Path: /images

    S3 files: /images/my-image.jpg

    GET Request: /images/my-image.jpg -> 403

    What was happening was the entire CloudFront GET request gets sent to the origin: /image/my-image.jpg prefixed by Origin Path: /images, so the request into S3 looks like /images/images/my-image.jpg which doesn't exist.

    Solution

    remove Origin Path.

提交回复
热议问题