Cloudflare Tunneling with Docker made easy with this handy guide from Bobcares.
At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.
Let’s take a look at how our Support Team is ready to help customers out with Cloudflare Tunneling with Docker
All About Cloudflare Tunneling with Docker
Let’s take a look at how to set up Docker for tunneling. Our Support Techs have come up with an easy guide to get the ball rolling. The process involves the following steps:
- Setting up Docker for tunneling
- Exposing a port to the internet
- Serving to a Domain Name using DNS
- Controlling tunnel processes
Setting up Docker for tunneling
We start out by installing a version of Docker in the main running process of the Linux server.
wget http://get.docker.io/builds/Linux/x86_64/docker-master.tgz tar -xf docker-master.tgz sudo cp ./docker-master /usr/local/bin
Then, we run a docker as seen below:
sudo docker run --name mynginx1 -P -d nginx
As seen above, we are running docker via a sudo command. This is because permissions on the binary require admin access. Then we launch an Nginx container on the port with the default port running in detached mode where the name is mynginx1.
Exposing a port to the internet
In order to be able to interact with Cloudflare’s tunnel, we have to install the tunnel’s binary:
wget https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.tgz tar xvzf cloudflared-stable-linux-amd64.tgz
Next, we log in to the Cloudflare command-line interface:
./cloudflared tunnel login
Then we add the domain to the dashboard. After that, Cloudflare manages all the certs in a single file. Alternatively, we can also export the certs from Cloudflare’s dashboard. This leads to a dashboard command-line-tool link like the one below:
https://dash.cloudflare.com/argotunnel?callback=https%3A%2F%2Flogin.argotunnel.com%2FOJhbhPndjt5VYDrx3bVPZHu1TiSQ6Bk69KPlGWO7gSM%3D
It is now time to save all the certs to ~/.cloudflared/. Although Argo Tunnel can handle this automatically, we may have to manually export the cert for from Cloudflare’s dashboard if Argo Tunnel is missing.
Serving to a Domain Name using DNS
Our Support Techs suggest running a tunnel connected to a running docker container with Cloudflare’s origin proxy server and Free SSL with this command:
./cloudflared tunnel --hostname domainname.com http://0.0.0.0:5003
Here, we use command tunnel and binary cloudflared to set up a connection between an open port. Furthermore, the –hostname flag generates an AAA record to domainname.com which we can see in the Cloudflare dashboard.
Controlling tunnel processes
Linux offers great support in running long-standing processes in an instance’s background. Our Support Team recommends using GNU Screen to automate the long-standing tunnel from Cloudflare. For instance:
screen -S 'domainname.com' ./cloudflared tunnel --hostname domainname.com http://0.0.0.0:5003
We can close a screening process with this command:
screen -X -S "sessionname" quit
We can view a screening process with the following command:
screen -ls
After this process, we will have a docker container running on port :5003 in addition to a site running on the domain name domainname.com with https:// rather than http://
[Looking for a solution to another query? We are just a click away.]
Conclusion
To conclude, our skilled Support Engineers at Bobcares demonstrated Cloudflare Tunneling with Docker.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
Hi, one question: How to tunnel the dsm https service using cloudflared? It seems that it is not possible (something to do with certificates I think). I only managed to do it using a cloudflared docker container pointing to the synology internal docker switch to the http dsm.
I know that cloudflare already convert http to https, but is it possible someway to use https in both ends without letting https data exploitable to the cloudflare agent?
Hello Fabio,
We’ll be happy to talk to you on chat (click on the icon at right-bottom).