How Do You Host Website on Amazon AWS_

How Do You Host Website on Amazon AWS?

At Volume Labs we have been working to convert our site from WordPress to a static site. In doing this we determined that Hexo was the best tool for us. When considering where to deploy the new site we instantly thought of AWS because they have a way to host static pages right out of S3. We have deployed Volume Labs and Volume Integration to AWS and I will show you how to in this post.

First create an S3 bucket. I named ours using the name of our website. AWS S3 buckets are a place you can store files on AWS and each bucket is unique across all users so our domain name should be unique. S3 is more cost efective than using an AWS server instance.

S3 Bucket Button aws


Create the Bucket

S3 is redundant as the data you store there is spread across at least three data centers. You pay for the amount of storage used and the bandwidth used to get it in and out of S3.

When you create the S3 bucket give it the following properties by clicking the properties button. This will configure it to act like a web host and serve up the web pages.

S3 Bucket Properties

Note your website address for the bucket. You will need this later.

Then configure the policy document to allow everyone on the internet read access to your files.

S3 Bucket Policy

S3 Bucket Policy

{ "Version": "2012-10-17", "Id": "Policy1477706476623", "Statement": [ { "Sid": "Stmt14777064735", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource":"*" } ] }

Upload your files to the S3 bucket. Use the upload button or the S3 api to upload your files.

Copy your website address that AWS gave you for the S3 bucket and test it out in a browser.

Now configure a certificate with Certificate Manager. Make sure you configure the certificate before you change the DNS settings for the provider of your domain name. When you request a certificate AWS will send you an e-mail to authorize it using the contacts in your dns entry. It will also try webmaster, hostmaster, administrator, postmaster and

Certificate Button

Request a certificate

Enter all of the domains that your site should respond to. Use your main domain name and www. at least. When you finalize your request AWS will send you an e-mail to validate your certificate. Make sure as the owner of your domain name that you have setup your domain registration to send you e-mail. If you have the MX record setup correctly with your domain name provider it will send you an e-mail.

Then we setup CloudFront. CloudFront allows for distribution of content across the world. It caches your content to many servers all over the world this puts the content closer to the people viewing it.

In CloudFront you can configure the connection to the S3 bucket and to the certificate. It is also possible to have it serve up the files with compression this will further improve the speed that your website is delivered to the browser.

CloudFront Button

Press the Create Distribution button. Pick the web delivery method on the next screen.

CloudFront Delivery Method

Set the origin settings. This is where you tell it to read the files from your S3 bucket. Paste in the url for your S3 bucket you saved earlier into the Origin Domain Name.

CloudFront Origin Settings

Now setup the Cache Behaviour. Since we are setting up a SSL TLS certificate turn on the Redirect http to https setting. Also turn on the compress objects setting to improve the speed of downloading your pages. Keep the other settings as is. You can reduce the Time To Live TLS if your pages change more often.

CloudFront Cache Behavior

For the worldwide coverage set the distribution behaviour to use all edge locations. It will push your pages out to servers all over the world. Enter the alternate domain names your site will use. And then set the custom SSL certificate to the one we created using the AWS Certificate Manager.

CloudFront Distribution Behavior

In addition turning off IPv6 will make it easier to deploy using Route 53. So I turned off IPv6 in the distribution behaviour section.

Press the Create Distribution to finish the work here in CloudFront.

After CloudFront finishes distributing your site use the url it generates to view your site. Save this url in order to configure Route 53. It is called that because the default port for DNS is port 53.

Now you need to configure Route 53. Route 53 is a DNS service on steroids with non of the side effects. This is the final step to getting your personal domain name to serve up the content.

Route 53 allows for aliases that will route the requests asking for your root domain and www. subdomain to the CloudFront distribution. It will also direct http traffic to https

Go to Route 53 in the AWS Console. Press the Create Hosted Zone button.

Route 53 Hosted Zone Button

Enter the top level domain name of your site. And press Create. You will see that some settings are created.

Route 53 Name Servers

Take the nameserver NS settings that are generated by Route 53 and enter them in the DNS settings at domain name provider. This will allow AWS Route 53 to act as your domain name service and give you all the nice features in Route 53.

The next step is to set up an alias that will guide requests to your pages sitting in CloudFront which is getting them from S3.

We need two alias routes set as record sets in this screen. So press the Create Record Set button.

Route 53 Alias Record

Click on the alias Yes radio button and enter the CloudFront url where your site is hosted from. Leave the name field blank. Then do it again. Create another record set with the name of www and set the alias to yes and enter the url for the CloudFront distributions again. This will create the route for the www sub domain for your site.

Now wait. It takes 1 to 48 hours for the worldwide network of DNS servers to get the changes you made at your domain name provider.

As another option you can purchase or move your domain name to AWS.

In order to set up e-mail forwarding I use this free e-mail forwarding service Improve MX. Just register your domain with ImproveMX and create a record set for a MX record in Route 53 with the mail server settings.

Now enjoy your site. You should see increased performace over a run of the mill web hosting provider and your costs might be lower.

Please follow use at VolumeInt. And check us out at Volume Integration

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *