0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AWS S3でStatic website hostingする際のReferer制御

Last updated at Posted at 2019-11-09

実現すること

AWS S3でバケットをStatic website hostingする際に

  • index.htmlのみ公開
  • それ以外のリソースはRefererでアクセス制御

します

やりかた

S3のバケットの
アクセス制限/バケットポリシー
にて以下を記載します

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Allow all to index.html",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::${S3_BUCKET_NAME}/index.html"
        },
        {
            "Sid": "Allow all from own domain",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::${S3_BUCKET_NAME}/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": "https://${S3_BUCKET_NAME}.s3-ap-northeast-1.amazonaws.com/*"
                }
            }
        }
    ]
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?