Self-Hosting WordPress Through Cloudflare Tunnels

Project Description

In this project, I set out to combine several tools and technologies to self-host a WordPress site. The idea was to purchase a domain from Cloudflare, use Proxmox and Docker to spin up a WordPress container, and then securely expose the site to the internet using Cloudflare’s services.

Objectives

Here’s what I aimed to achieve:

  • Self-host a WordPress instance with Docker using Docker Compose.
  • Expose the WordPress site through a domain I purchased from Cloudflare.
  • Keep the total cost at a grand total of $0.
  • Secure the site with HTTPS/SSL certificates.

The Journey

I kicked things off by setting up a virtual machine (VM) on Proxmox with Ubuntu as the operating system. Once the VM was up and running, I installed Docker to manage my containers. Using Docker Compose, I set up the WordPress instance, complete with a MySQL database to handle the backend.

One of the coolest parts of this project was leveraging Cloudflare and Cloudflare Tunnels. These tools helped me hide my public IP address and route my domain directly to my WordPress instance. It added an extra layer of security, which is always a good thing.

However, this project wasn’t without its challenges. The first major hurdle was getting the WordPress site accessible through my domain. Despite setting up everything correctly in Cloudflare’s DNS settings, I could only access the site locally. This was incredibly frustrating, and I spent a lot of time researching and trying different solutions. Finally, I stumbled upon a blog post that recommended using the “Better Search and Replace” plugin in WordPress. This plugin allowed me to replace all instances of the local IP address with my domain name. Once I did that, everything clicked into place, and I could access the site through my domain.

The second challenge was securing the site with HTTPS/SSL certificates. This was a bit more complex, and I’m still working on fully understanding and implementing it. It’s been a learning journey, and while the site is functional, securing it properly is my next big milestone.

Outcome

The project was a success! I can now access my WordPress site through my domain and create blog posts on it. The HTTPS/SSL setup is the next step I need to conquer, but overall, I’m really happy with how things turned out.

Lessons Learned

This project taught me a lot about DNS configurations and the importance of troubleshooting. Even if everything looks perfect on paper, there might be hidden configuration issues that need to be addressed. Reading documentation and utilizing Google as a resource were crucial in overcoming the challenges I faced. Plus, I learned to appreciate the intricacies of setting up and managing a self-hosted WordPress site.

Working through these challenges by myself—from installing the VM in Proxmox to setting up Docker and configuring Cloudflare Tunnels—has been incredibly rewarding. It reinforced the importance of persistence and continuous learning in the world of IT.

Updates

June 30, 2024
  • Update Title: SSL Certificate Successfully Implemented
  • Details: After hours and hours of troubleshooting, I finally have the SSL Certs working and the site running on HTTPS. I want to explain a bit about how I did it. I had to install Certbot on the Ubuntu server that is running Docker, which hosts my WordPress instance. Then, I was able to create the SSL certificate and set it to auto-renew through Certbot. I had to make adjustments to the file configuration within the WordPress instance through the command line. There was a lot of trial and error and a lot of searching on Google, but I finally found that I needed to create a custom SSL configuration file to use with Apache2. Additionally, I changed the .htaccess file of WordPress to point to HTTPS rather than HTTP.I also had to update the WordPress database to change the domain from HTTP to HTTPS. Lastly, I had to modify my Cloudflare tunnel configuration. It was originally pointing my domain to the local IP of WordPress through HTTP on port 80, but I had to change it to use HTTPS on port 443.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *