how to host a static website by using AWS S3, route-53 and godaddy domain

how to host a static website by using AWS S3, route-53 and godaddy domain

13.688 Lượt nghe
how to host a static website by using AWS S3, route-53 and godaddy domain
Configuring a static website on Amazon Web Services S3 You can configure an Amazon S3 bucket to function like a website. This example walks you through the steps of hosting a website on Amazon S3. Topics Step 1: Create a bucket Step 2: Enable static website hosting Step 3: Edit Block Public Access settings Step 4: Add a bucket policy that makes your bucket content publicly available Step 5: Configure an index document Step 6: Configure an error document Step 7: Test your website endpoint Step 8: Clean up Step 1: Create a bucket The following instructions provide an overview of how to create your buckets for website hosting. For detailed, step-by-step instructions on creating a bucket, see Creating a bucket. To create a bucket Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/. Choose Create bucket. Enter the Bucket name (for example, example.com). Choose the Region where you want to create the bucket. Choose a Region that is geographically close to you to minimize latency and costs, or to address regulatory requirements. The Region that you choose determines your Amazon S3 website endpoint. For more information, see Website endpoints. To accept the default settings and create the bucket, choose Create. Step 2: Enable static website hosting After you create a bucket, you can enable static website hosting for your bucket. You can create a new bucket or use an existing bucket. To enable static website hosting Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/. In the Buckets list, choose the name of the bucket that you want to enable static website hosting for. Choose Properties. Under Static website hosting, choose Edit. Choose Use this bucket to host a website. Under Static website hosting, choose Enable. In Index document, enter the file name of the index document, typically index.html. The index document name is case sensitive and must exactly match the file name of the HTML index document that you plan to upload to your S3 bucket. When you configure a bucket for website hosting, you must specify an index document. Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders. For more information, see Configuring an index document. To provide your own custom error document for 4XX class errors, in Error document, enter the custom error document file name. The error document name is case sensitive and must exactly match the file name of the HTML error document that you plan to upload to your S3 bucket. If you don't specify a custom error document and an error occurs, Amazon S3 returns a default HTML error document. For more information, see Configuring a custom error document. (Optional) If you want to specify advanced redirection rules, in Redirection rules, enter JSON to describe the rules. For example, you can conditionally route requests according to specific object key names or prefixes in the request. For more information, see Configure redirection rules to use advanced conditional redirects. Important The following policy is an example only and allows full access to the contents of your bucket. Before you proceed with this step, review How can I secure the files in my Amazon S3 bucket? to ensure that you understand the best practices for securing the files in your S3 bucket and risks involved in granting public access. Under Buckets, choose the name of your bucket. Choose Permissions. Under Bucket Policy, choose Edit. To grant public read access for your website, copy the following bucket policy, and paste it in the Bucket policy editor. { "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::Bucket-Name/*" ] } ] } Update the Resource to your bucket name.