Skip to content

Instantly share code, notes, and snippets.

@ahxxm
Last active December 25, 2025 05:23
Show Gist options
  • Select an option

  • Save ahxxm/83582a243e16ad98385c95776c00a902 to your computer and use it in GitHub Desktop.

Select an option

Save ahxxm/83582a243e16ad98385c95776c00a902 to your computer and use it in GitHub Desktop.
cloudflared + dufs to share files, sends URL to telegram chat
services:
fileserver:
image: sigoden/dufs
command: /srv --allow-search --allow-archive --compress none -p 80
volumes:
# dir to share
- /downloads:/srv:ro
tunnel:
image: alpine:latest
depends_on:
- fileserver
env_file:
# should look like this
# TG_BOT_TOKEN=123456:ABC
# TG_CHAT_ID=123456
- .env
command:
# amd64 / aarch64
- /bin/sh
- -c
- |
apk add --no-cache curl
wget -q "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64" -O /usr/local/bin/cloudflared
chmod +x /usr/local/bin/cloudflared
last_url=""
cloudflared tunnel --no-autoupdate --url http://fileserver:80 2>&1 | while read line; do
echo "$$line"
url=$$(echo "$$line" | grep -o 'https://[^[:space:]]*\.trycloudflare\.com' || true)
if [ -n "$$url" ] && [ "$$url" != "$$last_url" ]; then
curl -sf "https://api.telegram.org/bot$${TG_BOT_TOKEN}/sendMessage" \
-d "chat_id=$${TG_CHAT_ID}" \
-d "text=$$url"
last_url="$$url"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment