I have a NAS where I am running various web apps in docker containers through docker-compose. I want some of these web apps to be accessible through the internet, not only when I am connected to my home network.
The problem I'm currently facing is that while cloudflare is able to expose the default web apps (default NAS management 192.168.1.135:80
can be mapped to subdomain.domain.com
, for instance), it is unable to expose any docker container I try to run (192.168.1.135:4444
cannot be mapped to subdomain2.domain.com
), and I receive a 502 bad gateway error with every app I have tried so far.
The configuration shouldn't be the issue, and it's definitely not the NoTLSVerify
flag because the apps run on HTTP and I have configured it that way, so I am out of options to know what is going on and how to solve it.
Turns out the problem is due to how docker works with networks, not with how Cloudflare accesses them. I first had to create a network that connected both containers, since adding cloudflare to my docker-compose file didn't work for some reason.
docker network create tunnel
docker run -d --name cloudflare cloudflare/cloudflared:latest tunnel --no-autoupdate run --token
docker network connect tunnel cloudflare
docker-compose up
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container