Hosting on AWS #
The site is static, and completely hosted on AWS using a combination of S3 and Cloudfront. Here are the steps I followed to set it up.
- Create an AWS root account
- Use the root account to create an IAM user and perform all following actions as that user
- In Route53 purchase the domain sempercogitare.co.uk which will create a hosted zone for it
- In S3 create a bucket called www.sempercogitare.co.uk
- When creating it choose to block all public access to the bucket
- Add a test index.html into the root of the bucket
- In Cloudfront create a new function called add_index_html
function handler(event) {
var request = event.request;
var uri = request.uri;
// Check whether the URI is missing a file name.
if (uri.endsWith('/')) {
request.uri += 'index.html';
}
// Check whether the URI is missing a file extension.
else if (!uri.includes('.')) {
request.uri += '/index.html';
}
return request;
}
- In Cloudfront create a new distribution
- The origin will be the S3 bucket you have just created
- Under Origin access choose Origin access control settings
- Choose the Origin access control for the bucket
- Follow the instructions AWS gives you to add the policy to the S3 bucket. This gives this Cloudfront distribution access to the S3 bucket.
- Under Viewer protocol policy select Redirect HTTP to HTTPS
- Associate the add_index_html with Viewer request
- Under Settings, add CNAMEs for sempercogitare.co.uk and www.sempercogitare.co.uk
- Request a custom SSL certificate with FQDN sempercogitare.co.uk. Add a second name of www.sempercogitare.co.uk. Follow the instructions that AWS gives you to do this.
- Set the default root object to index.html
- Once the distribution has been created, grab its domain name (dddddddd.cloudfront.net) and head back over to Route53
- In Hosted zones select sempercogitare.co.uk and create a new record with the following properties
- subdomain - none (leave blank)
- record type - a
- value - dddddddd.cloudfront.net (the Cloudfront distribution domain name)
- Create another new record with the following properties
- subdomain - www
- record type - cname
- value - dddddddd.cloudfront.net (the Cloudfront distribution domain name)
- In Hosted zones select sempercogitare.co.uk and create a new record with the following properties
Test by visiting all variations:
- http://sempercogitare.co.uk
- http://www.sempercogitare.co.uk
- https://sempercogitare.co.uk
- https://www.sempercogitare.co.uk
All four should return the site.