nixmind
nixmind

Reputation: 2266

[AWS]s3 bucket web hosting not working

I'm googling since several hour without solution.

I'm trying to manage my bucket as web directory but it's not working fine.

Here is my bucket policy :

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my_bucket/*"
        }
    ]
}

I have an index html file at top level of the bucket, and a directory.

I can access the index file like this :

https://s3-eu-west-1.amazonaws.com/my_bucket/my_index_file.html

But all the following request give an xml access access denied error

https://s3-eu-west-1.amazonaws.com/my_bucket/

https://s3-eu-west-1.amazonaws.com/my_bucket

https://s3-eu-west-1.amazonaws.com/my_bucket/my_folder

https://s3-eu-west-1.amazonaws.com/my_bucket/my_folder/my_sub_folder

I haven't found a solution. Please let me konow if someone know how to achieve this, so that I can browse my bucket through firefox or another browser.

Thanks

Upvotes: 3

Views: 6916

Answers (2)

Aravind
Aravind

Reputation: 590

  1. You have to create 2 buckets, one for example.com and one for www.example.com
  2. Set bucket policy for both like below:

    { "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::example.com/" } ] }

  3. Follow this link : https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html

Upvotes: 0

Naveen Vijay
Naveen Vijay

Reputation: 16532

If you want to make the static website hosting with the necessary index.html & default pages - you need to enable S3 Static Website Hosting. Just making the files / S3 objects public wouldn't help the index.html routing.

Once you do that you would get URLs like - http://examplebucket.s3-website-us-east-1.amazonaws.com/

enter image description here

Checkout the following links

  1. http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html
  2. http://docs.aws.amazon.com/gettingstarted/latest/swh/website-hosting-intro.html

Upvotes: 2

Related Questions