Configuring A Static Website Using A Custom Domain Registered with Amazon’s Route 53

Step 1: Register a custom Domain with Route 53

Under the Services (Top Left) or All Services (Center Left) drop downs, find the Networking & Content Delivery section.

AWS Console
Dashboard for Route 53
Registered domain

Step 2: Create Two Buckets

To support requests from both the root domain and subdomain, you create two buckets.

1. Create your Root domain Bucket

a. Choose Create bucket.

2. Create your Subdomain Bucket

a. Choose Create bucket.

S3 Buckets

Step 3: Configure your root domain bucket for website hosting

Configure your root domain bucket (example.com) as a website. This bucket will contain your website content.

1. Follow these steps to enable static website hosting

a. In the Bucket name list, choose the bucket that you want to use for your static website.

  1. 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. For more information, see (Optional) configuring a custom error document.
  1. For more information, see Configuring advanced conditional redirects.
  2. Under Static website hosting, note the Endpoint.
  3. 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.
  4. Choose Save.
Properties of Bucket to Host Static Website
Properties of Bucket to Host Static Website

Step 4: Configure your subdomain bucket for website redirect

You can now configure your subdomain bucket to redirect all requests to the domain. In this example, all requests for www.example.com are redirected to example.com.

1. To configure a redirect request

a. Choose your subdomain bucket ( www.example.com in this example).

Properties for Static redirect
Properties for Static redirect

Step 5: Configure logging for website traffic

If you want to track the number of visitors accessing your website, you can optionally enable logging for your root domain bucket using S3; optionally you can use Amazon CloudFront to speed up your website and logging.

1. To enable server access logging for your root domain bucket

a. In the same Region where you created the bucket that is configured as a static website, create a bucket for logging, for example logs.example.com.

Log folder creation
Server logging

Step 6: Upload index and website content

When you enable static website hosting for your bucket, you enter the name of the index document (for example, index.html). After you enable static website hosting for the bucket, you upload an HTML file with this index document name to your bucket.

  • Drag and drop the index file into the console bucket listing.
  • Choose Upload, and follow the prompts to choose and upload the index file.

Step 8: Attach a bucket policy

After you edit S3 Block Public Access settings, you can add a bucket policy to grant public read access to your bucket. When you grant public read access, anyone on the internet can access your bucket.

Step 9: Test your domain endpoint

After you configure your domain bucket to host a public website, you can test your endpoint.

  1. In Buckets list, choose the name of the bucket that you want to use to host a static website.
  2. Choose Properties.
  3. Choose Static website hosting.
  4. To test your website endpoint, next to Endpoint, choose your website endpoint.
  5. If your browser displays your index.html page, the website was successfully deployed.

Step 10: Add alias records for your domain and subdomain

In this step, you create the alias records that you add to the hosted zone for your domain maps example.com and www.example.com. Instead of using IP addresses, the alias records use the Amazon S3 website endpoints. Amazon Route 53 maintains a mapping between the alias records and the IP addresses where the Amazon S3 buckets reside. You create two alias records, one for your root domain and one for your subdomain.

  • You configured the bucket as a static website.
  • The bucket name is the same as the name of the record that you’re creating.
  • The current AWS account created the bucket.
  1. In the hosted zone for your root domain (example.com), choose Create record.
  2. In Record name for your subdomain, type www.
  3. In Value/Route traffic to, choose Alias to S3 website endpoint.
  4. Choose the Region.
  5. Choose the S3 bucket, for example example.com (s3-website-us-west-2).
  6. In Record type, choose A ‐ Routes traffic to an IPv4 address and some AWS resources.
  7. For Evaluate target health, choose No.
  8. Choose Define simple record.

Step 11: Test the website

Verify that the website and the redirect work correctly. In your browser, enter your URLs. In this example, you can try the following URLs:

  • Domain (http://example.com) – Displays the index document in the example.com bucket.
  • Subdomain (http://www.example.com) – Redirects your request to http://example.com. You see the index document in the example.com bucket.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store