How to host a website on AWS using S3

I have read many blogs, forums and youtube videos to host a website using Amazon Simple Storage Service (S3).

I ran into some issues while hosting my website which I will address in this post. I will cover the issue of Apex (or naked or bare) Domains too.

I am in love with Amazon Web Services (AWS) eversince I am using it, I hope you will be glued to it too once you start working on it. Many of you might know, but still I would like to highlight that you can use various services of AWS for free for first 12 months.

Pre-Requisites

So lets start with what do you need to get this done.

  • Domain Name
  • Amazon Web Service Account
  • Few html pages

    First and foremost, register a domain name with any of the big players like GoDaddy, BigRock, OnlyDomains, Register, etc. These domain providers also manage your DNS records.

    I have registered my domain name with GoDaddy which is reachvikas.com.

    Downsides of hosting a website on Amazon S3

    There are certain limitations too when you use Amazon S3 for web hosting.

  • Only static pages can be hosted, this means no live data
  • No contact forms by default, but you use make use of some sites like wufoo and zapier. I have not tested these yet, feel free to share your experiences if you decide to use forms.

    Create buckets to store website files in Amazon S3

    Assuming by now, you've registered with Amazon. Login to Amazon console and click on S3 under Storage & Content Delivery.

    Let's say your domain is mys3example.com.

    We need to create two buckets

  • mys3example.com
  • www.mys3example.com

    These two buckets will help us to cater hits on both the URLs - http://mys3example.com and http://www.mys3example.com

    Follow the screenshots closely, to create these two buckets.

    NOTE: Though Amazon recommends to use Google Chrome (browser stucks on loading page), but sometimes I have faced issues with it. I would recommend Mozilla Firefox.

    Create a bucket mys3example.com. Carefully choose the region which is closest to you to avoid latency issues.

    Click on Properties (top right), then click on Permissions, and then on Add more permissions and choose the Grantee as Everyone from the drop down menu.

    Click on Static Website Hosting and enable website hosting

    Create another bucket www.mys3example.com

    Click on Static Website Hosting and then Redirect all requests to another host name

    Upload website files in S3 Buckets

    We only need to upload files in bucket mys3example.com. The other bucket can be left empty as it is only being used to redirect requests hitting on http://www.mys3example.com to http://mys3example.com

    Download the index.html and 404.html from here and upload these into the S3 bucket as shown below.

    Select both the files, right click and make them public

    Test the S3 Endpoints

    Click on the Endpoint URL as shown below

    This page should appear from index.html

    Manually insert some random text after the URL in the address bar of the browser to check 404.html

    If this is working for you, you're good to move on to my next post to manage your DNS records through Route 53

    Thanks for reading.

  • comments powered by Disqus