Architecture for setting up a fallback site using Route53

Have you ever faced downtime with your WordPress site? Amazon CTO, Werner Vogels says, “Everything fails, all the time”. So our primary WordPress site can also fail sometimes and we need a fallback site if that happens. This increases the website’s reliability and trust. Let me explain your, how to use Amazon S3 to set up a static website as a fallback site for WordPress by leveraging Amazon Route53.

Why should you use A static website hosted on S3 as fallback site for your WordPress site?

S3 static website is serverless so no need to pay for any servers.

Pay only when the primary site is down, except for S3 storage which is usually not very much.

Chances of failures of fallback site is less as S3 is fully managed service.

Note: Fallback site on S3 won’t support dynamic features such as comments and subscriptions.

Prerequisites

AWS account

wget or equivalent (Command line utility to download the contents of a webpage)

AWS CLI

You need to be using Route53 as a DNS resolver.

Steps for setting up the fallback site

Crawl your WordPress website

We need to first download all the contents of your existing WordPress site. To do so, you can execute the following commands:

# Create a new directory to keep the website contents mkdir myWordpressSite # Then change to the newly created directory cd myWordpressSite # After that use wget to download entire website using recursive crawling wget --no-host-directories --recursive --page-requisites --no-parent --timestamping <your-wordpress-site-url>

If you are using Apple MacOS or Windows, you can install wget using this link. NOTE: I have tested the above commands on MacOS 10.13 using wget installed using Homebrew. Don’t use this method to crawl the website which you don’t own. As you might be voilating the terms and conditions of that website.

Set up S3 bucket for hosting the fallback site

Create an S3 bucket with your WordPress site name.

Copy website contents to the S3 bucket using AWS CLI.

aws s3 sync . s3://<wordpress-site-domain-name>

Check my blog to set up the S3 bucket as a static website.

Setup up Cloudfront for SSL and caching support

S3 static web hosting currently doesn’t support SSL so in order to support SSL. So we can use Cloudfront as it supports SSL using Amazon Certificate Manager.

Create Cloudfront distribution with the S3 bucket as the origin by following my colleague Sumit’s blog.

Setup DNS failover on Route53

If you have not registered your domain on Route53 then you can refer my colleague Ravi’s blog. In this blog, he explains how to use a domain that is externally registered with Rout53 DNS resolver.

Create a health check to the WordPress site:

Health check for primary site

Use HTTPs if your WordPress site supports.

The domain name should be the hosting provider name. Example: tensult-blogs….mybluehost.me



Creating DNS records with failover

Primary DNS Recordset for Failover

Secondary Recordset for failover

Now you have successfully set up a fallback site for your WordPress website. If you want to test this failover, you do follow the above steps for your staging or testing sites and test it thereby manually bringing it down.

Conclusion

I hope you have understood, why and how to set up a fallback site for your WordPress. Please try these steps on your existing WordPress setup and let me know if you face any issues. Also, subscribe to our newsletter for more interesting updates.