Amazon S3에 정적 웹 호스팅하는 컨텐츠를 각 Front-end 생성기를 통해서 만들 수 있습니다.

이때, S3에서는 정상적으로 동작하는 웹 페이지가 CloudFront에서는 정상적으로 동작하지 않는 경우가 있습니다.


Amazon S3는 index.html을 URL 끝에 반드시 붙이지 않더라도 자동으로 해당 패스의 index.html 파일을 읽어와서 화면에 표시해 주는 기능을 제공합니다.

인덱스 문서(Index Document)는 웹 사이트의 루트나 임의의 하위 폴더로 요청이 전달되는 경우에 Amazon S3이 반환하는 웹 페이지입니다.

따라서, 특정 URL로 호출을 할 경우(www.example.com/), 기본 페이지라고도 하는 인덱스 문서(www.example.com/index.html)를 표시하도록 도와줍니다.


CloudFront의 오리진(Origin)을 S3 버킷이 아닌 S3 웹 호스팅 Endpoint URL로 설정할 경우, 이 기능을 활용할 수 있습니다.

CloudFront에 배포된 Origins 정보를 수정하는 메뉴에서 Origin domain 값을 S3 버킷의 정적 웹 호스팅을 위한 Endpoint URL로 변경하면 index.html 생략하고 CloudFront에서도 웹 사이트가 정상 동작하는 것을 확인할 수 있습니다.


이 자료에 대한 출처는 다음과 같습니다.

  1. Default index.html pages do not render in S3 website subfolders

    To get the default index/error page functionality, you will need to use the S3 static website URL. This looks something like "www.example.com.s3-website-us-east-1.amazonaws.com". If you set up a CloudFront distribution pointing to an S3 bucket, you will not get this functionality. CloudFront provides default root object support as well, but not for any subdirectories. You can solve this by using a custom origin instead. When CloudFront uses the S3 static website URL as the origin, you get the desired functionality.

  2. Amazon Cloudfront with S3. Access Denied

    • Enable static website hosting for the bucket
    • Set the Index (and perhaps Error) document appropriately
    • Copy Endpoint URL - you can find it next to the above settings - It should look something like: <bucket.name>.s3-website-<aws-region>.amazonaws.com
    • Use that URL as your CloudFront Distribution origin. (This will also make the CF Default Root Object setting unnecessary, but doesn't hurt to set it anyway)



  • 레이블 없음