How Do I setup Cloudflare Tunnel Container With Linode Firewall?
Hi folks!
Problem:
The Cloudflare tunnel (Zero Trust) does not link domain to web server.
Setup:
- Linode docker image
- Cloudflared tunnel container
- Web server : https://github.com/crccheck/docker-hello-world
- Linode Firewall
- Allow outboud I.e Egress traffic
- Drop Inbound I.e Igress traffic
- Using Lish console to start and monitor container
More Info:
I'm trying to setup Cloudflare Tunnel with my new instance of Linode but all i'm receiving is an Error 502 from my web browser.
It all worked fine when I used my own server at home (without opening any port on my router)
I used the cloudflared docker image to connect the tunnel to Cloudflare. (The tunnel says it is connected in the ui)
But when I try to link my domain test.example.com
to my linode isntance it never resolve. Either while linking to 0.0.0.0, 127.0.0.1, localhost, x.x.x.x (Linode isntance IP) and x.x.x.x.ip.linodeusercontent.com
Normally I can just set test.example.com
-> http://192.0.0.x:anyport
in cloudflare tunnel UI.
--
Actually, event with Inbound traffic enable, it doesn't work
-- More info found
The error I get from the cloudflared container is this :
cloudflared | 2023-12-16T22:28:15Z ERR Request failed error="Incoming request ended abruptly: context canceled" connIndex=3 dest=https://test.example.com/ event=0 ip=x.x.x.x type=http
cloudflared | 2023-12-16T22:28:47Z ERR error="Incoming request ended abruptly: context canceled" cfRay=Some-ID event=1 ingressRule=0 originService=http://my-linode-ip
-- Even more info
I tried t osee if my service was working as expected with the following command from the Linode isntance :
curl http://localhost:80
Hello World ## . ## ## ## == ## ## ## ## ## === /""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ \______ o _,/ \ \ _,' `'--.._\..--''
Having received this, I know taht the web server is working as expected
1 Reply
✓ Best Answer
Ok,
So, It was a Docker Issue where the networking didn't work as it was on my host machine.
To resolve the issue, we need to see and connect the corresponding container to the same network.
So I resolve this issue by creating a bridge network
sudo docker network create cloudflare-to-web-test
Then connect the containers to it
sudo docker network connect cloudflared
sudo docker network connect web-test
The the rest will be automagically resolved