Static Website Hosting on Amazon S3
You can use s3 to store and serve static media like html or images. This is perfect for internal emails and reports.
Before you begin
- The enpoint provided does not use https so do not use this method for anything with sensitive data without setting up https.
content-typeheader for the files uploaded to s3 is important. If they are not set correctly, the browser will show a “Save as” window instead of rendering the html or image file. When uploading files theough the s3 console the header is detected and set automatically. If you are uploading files programatically, this header should be set manually.
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.
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 XML 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.
Choose Save changes.
Amazon S3 enables static website hosting for your bucket. At the bottom of the page, under Static website hosting, you see the website endpoint for your bucket.
Under Static website hosting, note the Endpoint.
The Endpoint is the Amazon S3 website endpoint for your bucket. After you finish configuring your bucket as a static website, you can use this endpoint to test your website.