Cloudflared docker has Cloudflare Tunnel client which can easily and securely exposes private services to public through the Cloudflare edge network. This blog post shows you how to deploy this Cloudflared docker into PaaS plaform such as Codesandbox.io to map your sub domain to the apps from private PaaS network to public.
With this Cloudfalred docker, You can then use it to expose:
- Private HTTP-based services exposed on a public DNS hostname, optionally locked down by Cloudflare Access (see https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/ and https://developers.cloudflare.com/cloudflare-one/applications/configure-apps/self-hosted-apps/ )
- Private networks accessed by TCP/UDP IP/port by WARP enrolled users, with a Zero Trust approach, to squash away your legacy VPN (see https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/private-net/ )
Note: Here is another way to map your domain to Codesandbox PaaS, which is to use vercel, as shown from github project: https://github.com/k0baya/reserve-vercel/.
Codesandbox Free Tier
Up to 40 hours worth of VM credits per month VMs up to 4 vCPUs + 8 GiB RAM 5 private Sandboxes Unlimited public Sandboxes Unlimited Devboxes and repositories 5 members
Private Sandboxes, Devboxes & repos 100 Codeium AI code completions Live collaboration VS Code extension Instant environment resume Instant environment share
Usage status:
Every month, you will get 400 credits to use, which is 40 hours for a Nano vm.
Steps to Create a Cloudflared Docker with APP
1 Create your workspace box, either devbox or sandbox
2 Create Docker
You will be only able to select Devbox for this type of template:
3 Modify tasks.json file under workspace/.codesandbox
{ // These tasks will run in order when initializing your CodeSandbox project. "setupTasks": [ { "name": "Deploy", "command": "cd /project/workspace/.devcontainer/ && docker compose up -d" } ],
// These tasks can be run from CodeSandbox. Running one will open a log in the app. "tasks": { "cloudflare": { "name": "cloudflare", "command": "cloudflare", "runAtStart": true } }}
4 Create docker-compose.yaml file under workspace / .devcontainer
Once you pressed ctrl+s to save docker-compose.yaml file, it will ask you to rebuild & restart the deccontainers.
Manual Running the docker if task does not work:
Open a shared Terminals
Run following commands:
- cd /project/workspace/.devcontainer/ && docker compose up -d
Cloudflare
3. Test the public domain
Other Settings
Check System usage
Port forwarded Address
Other apps
version: "3.8"services: uptime-kuma: image: louislam/uptime-kuma:1 container_name: uptime-kuma volumes: - /project/sandbox/uptimekuma:/app/data ports: - "5700:3001" # <Host Port>:<Container Port> restart: always
cloudflared: restart: always network_mode: host environment: - tz=america/new_york command: tunnel --edge-ip-version auto --protocol quic --heartbeat-interval 10s run --token eyJhIjoiN2YzNjkyNmRlOTI3ZWQ3NmEwYThhOGYyNWFhZjMxOGMiLCJ0IjoiODQ3YzM3NTctODRhZC00YjExLTliNzAtMmNiZmUwZjgzYmNhIiwicyI6Ik1qTTJZekV5T1RndFkyVXdPQzAwWkRCaExUaGpZbVF0WkRVMk1ETTRNREl3TldSbSJ91 container_name: cloudflared image: cloudflare/cloudflared:latest
Keep System Active
Online Monitoring Codesandbox url such as https://t2s3qd-5700.csb.app this url:
Videos
Docker Compose
Create docker-compose.yaml file under workspace / .devcontainerHFS
services:
hfs:
ports:
- 8080:8080
environment:
- HFS_CREATE_ADMIN=password123
- HFS_PORT=8080
image: rejetto/hfs:v0.53.0
You might want to mount your own configuration file folder and file folder into the docker-compose.yaml file configuraiton.
services:
hfs:
ports:
- 8080:8080
environment:
- HFS_CREATE_ADMIN=password123
- HFS_PORT=8080
image: rejetto/hfs:v0.53.0
cloudflared:
restart: always
network_mode: host
environment:
- tz=america/new_york
command: tunnel --edge-ip-version auto --protocol quic --heartbeat-interval 10s run --token <Your Token>
container_name: cloudflared
image: cloudflare/cloudflared:latest
If add following code into docker-compose.yaml file, it wont work properly:
volumes:- ./hfsconf:/home/hfs/.hfs # for hfs conf persistence
- ./myDisk:/app/myDisk # for your files
# don't forget to share volumes to access certificate files
Qinglong
Alist
Halo
Microsoft_365_E5_RenewX
Pandora-Next
Uptime-Kuma
KodBox
Zfile
PanIndex
ShareList
Cloudreve
Typecho
Baota_Panel
WordPress
Memos
Ghost
NGINX-ui
References
- https://github.com/k0baya/xiaoya_alist_docker_on_render
- 在 CodeSandBox 上部署docker并使用Cloudflare Tunnel打通自己的域名——以 青龙面板 为例
- 在CodeSandBox上部署docker并使用Cloudflare Tunnel打通自己的域名 - https://www.kuggg.org/archives/1705762042019
- 适用于 CodeSandBox 的 Docker Compose 配置 - https://www.kuggg.org/archives/1705763942662
- CodeSandbox - Getting started with Docker
No comments:
Post a Comment