0

I have an s3 bucket myBucket with two websites in it. First website is at root and the second one is in the folder abc. A CloudFront distribution has been configured on myBucket and its working successfully since an year. Here is the cloudfront access identity policy on the bucket.

{
    "Version": "2008-10-17",
    "Id": "PolicyForCloudFrontPrivateContent",
    "Statement": [
        {
            "Sid": "1",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXXXXXXXXXXX"
            },
            "Action": "s3:GetObject",
            "Resource": [
                "arn:aws:s3:::myBucket",
                "arn:aws:s3:::myBucket/*"
            ]
        }
    ]
}

Since the cloudfront identity has access to all the bucket its successfully serving the pages from the bucket folder myBucket/abc when accessed through https://myexample.com/abc/index.html but when refreshed its downloading a blank file with the name download. These two websites are linked and hence needed to keep them in the same bucket. Is there anyway how i can get rid of this download ? Also should i have to create another origin and the corresponding behavior to do this right ?

hakuna
  • 6,243
  • 10
  • 52
  • 77
  • 2
    Hey, this made me curious, so I googled a little - did you already find and confirm [this](https://forums.aws.amazon.com/thread.jspa?threadID=235334)? – Maurice Dec 11 '18 at 18:11
  • I checked it, its a different issue. For me /abc/index.html is being served but only when i refresh its downloading a blank file. Also i did not configure my s3 bucket to host a website – hakuna Dec 11 '18 at 18:21
  • 1
    Does this happen when you're using a different browser as well? This behavior seems very strange... – Maurice Dec 11 '18 at 18:23
  • Yes its happening in chrome and firefox. with IE its showing a blank page but when i put the actual redirected path its downloading it too. – hakuna Dec 11 '18 at 18:42
  • 1
    Could you run `curl` against the `/abc/index.html` as described in the answer to [this question](https://stackoverflow.com/questions/18296875/amazon-s3-downloads-index-html-instead-of-serving/18297039) - does the output change when you run it multiple times? – Maurice Dec 11 '18 at 18:55
  • Ran curl. Content-Type is text/html and not tag for Content-Disposition, so the metadata is as expected – hakuna Dec 11 '18 at 19:09
  • Hosting the website through s3 is serving both the websites right but not through cloudfront – hakuna Dec 12 '18 at 03:14

0 Answers0