Getting WordPress to Work On Cloudflare Tunnels

In Video by dbtech

Hey guys! I recently had someone ask if I could make a video about how to set up WordPress in Docker to work with Cloudflare tunnels.

So that’s what we’re going to do in today’s video!

Just know that this video will assume that you have a general understanding of how to deploy a Docker container as well as a general knowledge of what a CloudFlare tunnel is and how to set one up.

If you’re not sure about either of those topics, I’ll have links below with more info.

Now I’ve covered both how to install WordPress in Docker as well as how to set up CloudFlare tunnels, so when the question was posed to me about this, I was kind of confused.

“How hard could this be? It’s about as straightforward as you can get” I thought.

Now. There are 2 ways this could go. You could spin up your WordPress container with a database, create a tunnel over on CloudFlare with a domain name and all the stuff that goes with creating a tunnel and then go to the URL and everything just works.

YAY!

Or you could go through what I went through initially:

I spun up a WordPress container using a docker-compose in command line. I just used the default information provided in WordPress’ hub.docker.com page. You can change the port and the storage as necessary for your setup. I actually prefer to use mapped storage for setups like this rather than using Docker volumes. It’s just easier to manage things from my experience. I would highly suggest changing the uernames and passwords for the database as well as the database name itself in both parts of the Docker compose.

Then I logged into Cloudflare, headed over to the Zero Trust section of their site, and configured a new tunnel. I gave it a name, installed the tunnel agent for Debian (you can use the Docker method if you like, but I prefer the Debian method for my setup), and then created my subdomain and attached it to my domain name. (The subdomain is optional).

Then I changed the Service Type to HTTP, put in the IP address and port and clicked “Save hostname”.

Next I went to the URL I set up only to be greeted with this message explaining that there’s an issue connecting to the database.

No kidding. I haven’t install WordPress yet.

I looked through the container logs for WordPress and that didn’t help.

Honestly I was confused for a bit so I just walked away.

A few days later I came back. I figured coming back with a clear head would fix the issue, right?

So I spun up a WordPress container using a docker-compose in command line. I just used the default information provided in WordPress’ hub.docker.com page. You can change the port and the storage as necessary for your setup. I would highly suggest changing the uernames and passwords for the database as well as the database name itself in both parts of the Docker compose.

Then I logged into Cloudflare, headed over to the Zero Trust section of their site, and configured a new tunnel. I gave it a name, installed the tunnel agent for Debian (you can use the Docker method if you like, but I prefer the Debian method for my setup), and then created my subdomain and attached it to my domain name. (The subdomain is optional).

Then I changed the Service Type to HTTP, put in the IP address and port and clicked “Save hostname.

Next I went to the URL I set up only to be greeted with this message explaining that there’s an issue connecting to the database.

No kidding. I haven’t install WordPress yet.

So to troubleshoot, I went to the local IP Address of the container and the install script started and I was asked to choose my install language.

Weird.

So I grabbed the part of the URL that was added to the IP and port (/wp-admin/install.php) and went back to my URL page and tacked it onto the domain name.

And there it is. Now I can complete the installation process of WordPress in Docker using a Cloudflare tunnel!

Resource Links

My WordPress video:

The Docker-compose I used:
https://hub.docker.com/_/wordpress

My Cloudflare tunnels video:

CloudFlare Docker-compose (if you want to go that route):
https://dbt3ch.com/books/access-your-self-hosted-services-without-port-forwarding/page/cloudflare-tunnels-docker-compose

Getting WordPress to Work On Cloudflare Tunnels

In Video by dbtech

Hey guys! I recently had someone ask if I could make a video about how to set up WordPress in Docker to work with Cloudflare tunnels.

So that’s what we’re going to do in today’s video!

Just know that this video will assume that you have a general understanding of how to deploy a Docker container as well as a general knowledge of what a CloudFlare tunnel is and how to set one up.

If you’re not sure about either of those topics, I’ll have links below with more info.

Now I’ve covered both how to install WordPress in Docker as well as how to set up CloudFlare tunnels, so when the question was posed to me about this, I was kind of confused.

“How hard could this be? It’s about as straightforward as you can get” I thought.

Now. There are 2 ways this could go. You could spin up your WordPress container with a database, create a tunnel over on CloudFlare with a domain name and all the stuff that goes with creating a tunnel and then go to the URL and everything just works.

YAY!

Or you could go through what I went through initially:

I spun up a WordPress container using a docker-compose in command line. I just used the default information provided in WordPress’ hub.docker.com page. You can change the port and the storage as necessary for your setup. I actually prefer to use mapped storage for setups like this rather than using Docker volumes. It’s just easier to manage things from my experience. I would highly suggest changing the uernames and passwords for the database as well as the database name itself in both parts of the Docker compose.

Then I logged into Cloudflare, headed over to the Zero Trust section of their site, and configured a new tunnel. I gave it a name, installed the tunnel agent for Debian (you can use the Docker method if you like, but I prefer the Debian method for my setup), and then created my subdomain and attached it to my domain name. (The subdomain is optional).

Then I changed the Service Type to HTTP, put in the IP address and port and clicked “Save hostname”.

Next I went to the URL I set up only to be greeted with this message explaining that there’s an issue connecting to the database.

No kidding. I haven’t install WordPress yet.

I looked through the container logs for WordPress and that didn’t help.

Honestly I was confused for a bit so I just walked away.

A few days later I came back. I figured coming back with a clear head would fix the issue, right?

So I spun up a WordPress container using a docker-compose in command line. I just used the default information provided in WordPress’ hub.docker.com page. You can change the port and the storage as necessary for your setup. I would highly suggest changing the uernames and passwords for the database as well as the database name itself in both parts of the Docker compose.

Then I logged into Cloudflare, headed over to the Zero Trust section of their site, and configured a new tunnel. I gave it a name, installed the tunnel agent for Debian (you can use the Docker method if you like, but I prefer the Debian method for my setup), and then created my subdomain and attached it to my domain name. (The subdomain is optional).

Then I changed the Service Type to HTTP, put in the IP address and port and clicked “Save hostname.

Next I went to the URL I set up only to be greeted with this message explaining that there’s an issue connecting to the database.

No kidding. I haven’t install WordPress yet.

So to troubleshoot, I went to the local IP Address of the container and the install script started and I was asked to choose my install language.

Weird.

So I grabbed the part of the URL that was added to the IP and port (/wp-admin/install.php) and went back to my URL page and tacked it onto the domain name.

And there it is. Now I can complete the installation process of WordPress in Docker using a Cloudflare tunnel!

Resource Links

My WordPress video:

The Docker-compose I used:
https://hub.docker.com/_/wordpress

My Cloudflare tunnels video:

CloudFlare Docker-compose (if you want to go that route):
https://dbt3ch.com/books/access-your-self-hosted-services-without-port-forwarding/page/cloudflare-tunnels-docker-compose