Self-Host WordPress website securely in my Home Lab VM using CloudFlare Tunnel.

Self-Host WordPress website securely in my Home Lab VM using CloudFlare Tunnel.

More and more service providers are moving towards eliminating their free tyre or crippled offerings, so you have to upgrade if you want to host your hobby projects. It is surely good for their business, but it frustrates me. So I wanted to host my small app on home-server.

Prerequisite

You must be familiar with Linux, Terminal, and installing and configuring Ubuntu servers.

Software

I'm using Docker and WordPress together with a VirtualBox VM for this tutorial. I'll be hosting my WordPress site to the internet using CloudFlare Tunnel.

I can host multiple websites using a single tunnel, and Cloudflare will handle SSL and CDN security. I'll be hosting this app in a proxmox container for my home lab version.

Comparison

So let's compare to what is currently available.

Railway Provides 500 FREE Hours. Render Provides 750 FREE Hours, but sleeps after 15 minutes of inactivity. SelfHost: Constantly active utilising your own connections and hardware. I have more than enough hardware to run WordPress with my 500GB HDD, 16 GB RAM, and 6 Core CPU.

So for me SelfHost is a win.

Setup VM

I chose docker while installing Ubuntu so I wouldn't have to install it individually. Now I manage Docker using Portainer, which has a straightforward GUI.

To install a portainer, I am following to this official tutorial.

WordPress Setup

I will now use the "App Template" menu on the left to deploy the WordPress stack. I'll host to my 49125 port as well. WordPress is pre-configured; all that is needed to install it is a username and database password.

So that the CloudFlare tunnel can find it, kindly make the port static. Please don't install WordPress right away because it is now ready. After successfully setting up the tunnel, we'll install WordPress so that it can be configured with a https domain name.

Wordpress Setup

Setup CloudFlare Tunnel

To configure your cloudflare and put it up as a service, kindly follow this tutorial.

I'll now set up my config.yml file to contain the CloudFlare tunnel credentials. Here is a demo config file please replace the value.

tunnel: please-input-your-tunnel-id-here
credentials-file: /home/user/.cloudflared/please-input-your-tunnel-id-here.json

ingress :
      - hostname: wordpress.example.site
        service: http://localhost:49125
      - service: http_status:404

Now we need to restart CloudFlare Tunnel service ​​

systemctl restart cloudflared

Visit your "wordpress.example.site" site now to complete the configuration.

So that's it. Without having any prior networking experience, you are now self-hosting your WordPress website inside of a virtual machine.