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 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.
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.
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 firstname.lastname@example.org
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.
Press the Create Distribution button. Pick the web delivery method on the next screen.
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.
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.
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.
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.
Enter the top level domain name of your site. And press Create. You will see that some settings are created.
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.
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.