Cloudflare’s Automatic Platform Optimization makes it possible to self-host high availability WordPress sites from your home

Until now, I would have never recommended to anyone that they should host their WordPress site from their home network, but Cloudflare’s Automatic Platform Optimization (APO) has changed my mind. Here’s why it’s now a viable option.

WordPress and Cloudflare

I’m a big fan of WP Engine and I prefer to use managed hosting for sites that I consider mission-critical. However, I’ve always entertained the idea of running a web server from my home network, but there are two main reasons why I haven’t. First, I don’t want to expose and associate my home’s IP with the site. And second, I have a consumer internet plan – albeit fast – that’s not designed for web hosting.

When Cloudflare launched its Automatic Platform Optimization (APO) service for WordPress, a core feature was its ability to host a near-static version of the site using service workers. That got me thinking about how well it might work for a self-hosted site on my home network. I decided to set it up, and I was pleasantly surprised by the results and the cost.

How to self-host WordPress on a home network using APO

You will need a dedicated computer that’s always online. For me, that’s a headless Mac mini that I manage via Remote Desktop. Ideally, the computer shouldn’t be used for anything other than hosting and perhaps as a media and file server. I also recommend doing a clean install of the operating system.

Setting up the hosting environment

The next step is to add a hosting environment to the computer. The easiest way is to use MAMP Pro. MAMP Pro is an app that works on Mac or Windows and has everything you need to host a WordPress site.

MAMP Pro interface

The more complicated way is to install Apache, PHP, and a MySQL-compatible database manually. The advantage to that is everything runs in the background as a service and is typically more stable.

I chose to do it in a more complicated way. Fortunately, Andy Miller published excellent instructions on installing Apache and PHP on macOS Big Sur and how to install MariaDB, a MySQL compatible database. (Sorry Windows users. The instructions are only for macOS, but I’m sure there are good instructions for Windows out there too.)

The final step is to download and install WordPress. It got a little tricky for me because I initially installed it for http://localhost and then changed it to the domain name I was using after completing the Cloudflare setup. I was able to access the site, but I wasn’t able to access the Admin anymore. I eventually fixed it by simply changing the site to the non-secure (http) version of my domain name. Adding https caused a redirection loop because of how Cloudflare works. And even though the WordPress settings have http, it will still use https in the browser when you access it.

Configuring the modem and router

This is the part where you might have the most difficulty. Everyone has different equipment and connection types, but you must do some fundamental things to make the site publicly accessible.

IP Passthrough and NAT/Gaming

If you use a router behind the ISP’s modem, as I do with the AmpliFi Alien, you must enable Passthrough from the modem to the router. That passes the public IP address to the router. If you use the ISP’s modem and router that came with the service, you shouldn’t have to worry about enabling Passthrough.

IP Passthrough
IP Passthrough settings on AT&T Fiber Arris BGW210-700 modem

You may also need to add NAT/Gaming entries on the modem. I added entries for port 80 and 443 to allow HTTP and HTTPS traffic.

NAT Gaming
NAT/Gaming settings on AT&T Fiber Arris BGW210-700 modem

Static Lease

The computer will need a static lease from the DHCP server on your router. This will make it so the IP address never changes, which is important for port forwarding.

Static Leases
Static Lease on AmpliFi Alien router

Port Forwarding

The last requirement for the router is to set up port forwarding. This will forward all public traffic using port 80 and 443 to the computer used as a server. The IP address should be the same IP used for the static lease.

Port Forwarding
Port Forwarding on AmpliFi Alien router

Configuring Cloudflare

Add the domain to Cloudflare if it hasn’t already been added, and choose the Free plan. Then add an A Record with the public IP for your home internet.

Cloudflare DNS Record
A Record in Cloudflare DNS Manager

Most home internet services don’t use static IPs, but they also rarely change. However, if your IP changes often or you’re worried about it changing, you can set up a dynamic DNS service that will monitor and change the IP on Cloudflare automatically. Cloudflare has details on how to set it up, and they recommend using DNS-O-Matic. Also, if you’re using MAMP Pro, then you’re in luck. DNS-O-Matic is built into the app.

Next, you need to install and activate the Cloudflare plugin and configure APO on Cloudflare. Follow the instructions in this Coywolf News article to do that.

After that, if you’ve done everything correctly, you’ll be able to access your site using the domain you set up.

Self-Hosted Site
Self-hosted site using Cloudflare’s APO

The benefits of self-hosting with Cloudflare’s APO

Cloudflare’s APO not only performed well, but it also addressed the issues I mentioned at the beginning of the article. These are the benefits I discovered from using it.

Related Articles

Jon is the founder of Coywolf and the EIC and the primary author reporting for Coywolf News. He is an industry veteran with over 25 years of digital marketing and internet technologies experience. Follow @[email protected]