As of September the 20th, my site is hosted on Microsoft Azure, more specifically an Azure Storage account, using the Static Website feature! By making my site have a static front-end, the need to run it on script-enabled web-servers is gone and it can run on pretty much any host you can think of. Also by removing access to the dynamic scripts (WordPress back-end), the site’s attack surface decreased to 1/10 on an imaginary scale.
Previously my site was hosted on a donated cPanel web-host and for the small traffic my site gets, it was mostly fine. The donor however indicated they could no long provide the service and thus my hunt for a replacement host started. I wanted something new and a solution that would give me more peace-of-mind when it comes to maintaining the site. Having an unpatched WordPress install is a bad idea and the number of exploits of the worlds most popular blogging solution has skyrocketed lately.
So I could just get another PHP webhost or an Azure Web App to run my site, done deal but that still means I have to look after the software versions, plugin updates et cetera. I briefly considered using a managed WordPress host but they end up costing your a fair buck, especially if you want to host plugins or run big themes. A big trend in the open-source community is to export/generate a static-only version of their content and host it on GitHub Pages or ReadTheDocs.
Having a static site means no dynamic scripts or SQL statements to abuse or slow down your site but it will require some work to get it working when your site relies on said scripting. Often functionality like search, commenting and publishing require the dynamic PHP+SQL back-end and you’ll have to replace them with alternatives. The flow for the site is as follows:
- Host the site on a private/disconnected PHP/MySQL server (a LAMP VM on your laptop should be fine).
- Export a static copy of your site (for instance using the WP2Static plugin for WordPress).
- Create an Azure Storage account and enable the static website feature. Be sure to enable a custom domain name for hosting your site on a friendly URL.
- Upload the static copy to your Storage Account using AzCopy.
- Optional but recommended: Add a CDN to TLS enable and cache your website. I use CloudFlare because it provides DNS hosting and TLS-enabled CDN features at no extra cost. Azure CDN can also provide front-end caching but when I tested it, I didn’t want to add my root-domain, only sub-domains.
Alternatives to Azure Storage Accounts are Amazon S3 or GitHub Pages but for me Azure was a great fit. I’ll write a more complete how-to on how I migrated from a PHP-powered WordPress to an Azure-hosted static website.