Static Website Hosting on Amazon S3
How to host static website on Amazon S3
Static Website Hosting feature allows you host your static website on Amazon S3.
When a request is made to the root of your bucket configured as a website, Amazon S3 returns a root document.
You may also configure Amazon S3 Bucket to return your own error documents when a 4xx-class error occurs.
With S3 Browser Freeware you can easily enable static website hosting for your bucket.
To configure Amazon S3 Bucket as a Website
1. Select the bucket, you want to configure as a website.
2. Click Buckets->Edit Website Configuration
Click Buckets->Edit Website Configuration or use Ctrl+W keyboard shortcut
The Website Configuration Dialog will open:
Website Configuration Dialog allows you to configure website features for amazon s3 bucket
3. Select Enable static website hosting for [bucketname]
4. Specify Index document and optionally Error document
Index document will be returned for requests made to the root of your website or for any subdirectory.
For example, a GET request made to the following URI (directly or via a CNAME):
mywebsitedomain.s3-website.us-east-1.amazonaws.com/images/subdirectory/
Will return the following S3 object:
mywebsitedomain.s3.amazonaws.com/images/subdirectory/index.html
Error document will be returned when a 4XX error occurs. This parameter is optional.
If no Error document specified, Amazon S3 will return a new HTML error page instead of the current XML error.
5. Click OK to save changes and close the dialog
Bucket name should conform with DNS requirements:
- Should not contain uppercase characters
- Should not contain underscores (_)
- Should be between 3 and 63 characters long
- Should not end with a dash
- Cannot contain two, adjacent periods
- Cannot contain dashes next to periods (e.g., "my-.bucket.com" and "my.-bucket" are invalid)
Static website should be accessed via the region-specific website endpoint.
The website endpoint you use must be in the same region that your bucket.
Below is the table with Amazon S3 regions and corresponding website endpoints.
US East (N. Virginia) | s3-website.us-east-1.amazonaws.com |
US East (Ohio) | s3-website.us-east-2.amazonaws.com |
US West (N. California) | s3-website.us-west-1.amazonaws.com |
US West (Oregon) | s3-website.us-west-2.amazonaws.com |
Canada (Central) | s3-website.ca-central-1.amazonaws.com |
EU (Ireland) | s3-website.eu-west-1.amazonaws.com |
EU (London) | s3-website.eu-west-2.amazonaws.com |
EU (Paris) | s3-website.eu-west-3.amazonaws.com |
EU (Frankfurt) | s3-website.eu-central-1.amazonaws.com |
EU (Stockholm) | s3-website.eu-north-1.amazonaws.com |
EU (Milan) | s3-website.eu-south-1.amazonaws.com |
EU (Zurich) | s3-website.eu-central-1.amazonaws.com |
EU (Spain) | s3-website.eu-south-2.amazonaws.com |
Asia Pacific (Mumbai) | s3-website.ap-south-1.amazonaws.com |
Asia Pacific (Singapore) | s3-website.ap-southeast-1.amazonaws.com |
Asia Pacific (Sydney) | s3-website.ap-southeast-2.amazonaws.com |
Asia Pacific (Tokyo) | s3-website.ap-northeast-1.amazonaws.com |
Asia Pacific (Seoul) | s3-website.ap-northeast-2.amazonaws.com |
Asia Pacific (Jakarta) | s3-website.ap-southeast-3.amazonaws.com |
Asia Pacific (Osaka) | s3-website.ap-northeast-3.amazonaws.com |
South America (Sao Paulo) | s3-website.sa-east-1.amazonaws.com |
Asia Pacific (Hong Kong) | s3-website.ap-east-1.amazonaws.com |
AWS GovCloud (US) | s3-website.us-gov-west-1.amazonaws.com |
Middle East (Bahrain) | s3-website.me-south-1.amazonaws.com |
Middle East (UAE) | s3-website.me-central-1.amazonaws.com |
Africa (Cape Town) | s3-website.af-south-1.amazonaws.com |
How to manage redirections for static website.
You may also define redirection rules to automatically redirect web page requests for specific content.
To configure redirection rules:
1. Click the Website redirection rules link located at the bottom of the Website Configuration dialog.
Click the Website redirection rules link
Website Redirection Rules dialog will open:
Enter redirection rules and click Save changes
2. Specify routing rules using XML and click Save changes
Redirection Rules examples:
Redirect all requests from folder docs to folder documents
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>docs/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>documents/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
You can find more details about syntax for specifying routing rules and additional examples in
AWS Documentation.
To redirect all requests to another host
1. Select the bucket and click Buckets->Edit Website Configuration:
Click Buckets->Edit Website Configuration or use Ctrl+W keyboard shortcut
The Website Configuration Dialog will open:
How to redirect all requests to another host name
2. Select Redirect all requests to another host name
3. Specify host name
4. Specify the Protocol for redirection:
-
http
-
https
-
protocol as in the original request
5. Click OK.
|