generated from john/python-template
2.4 KiB
2.4 KiB
Cloudflare Tunnel and Access Setup
This guide defines the repository-supported setup for exposing app and selected LAN services through Cloudflare Tunnel with Cloudflare Access protection.
1. Files used by this deployment
deploy/cloudflared/config.yml(local copy fromconfig.yml.example).env.production(CLOUDFLARE_TUNNEL_TOKEN)docker-compose.production.yml(cloudflaredservice reads token + mounts config)
Do not commit config.yml or .env.production.
2. Configure cloudflared
- Copy
deploy/cloudflared/config.yml.exampletodeploy/cloudflared/config.yml. - Update hostname -> service mappings in
ingress. - Keep the final catch-all ingress
http_status:404. - Set
CLOUDFLARE_TUNNEL_TOKENin.env.production.
Example app route:
transcription.example.com->http://app:8000
Optional generic remote-access routes:
homeassistant.example.com->http://<home-assistant-lan-ip>:8123pihole.example.com->http://<pihole-lan-ip>:80
3. Cloudflare Access policy baseline
Create one Access app policy per exposed hostname:
- Include: your allowed identities/groups only.
- Exclude: none by default.
- Require: identity provider login (and MFA if available).
Recommended baseline:
- App endpoint (
transcription.*): your admin identity set. - Other internal endpoints (
homeassistant.*,pihole.*, etc.): explicit least-privilege groups.
4. Startup
Start production stack:
docker compose --env-file .env.production -f docker-compose.production.yml up -d --build
Validate tunnel container:
docker compose --env-file .env.production -f docker-compose.production.yml logs cloudflared
LXC/proxied-network note:
- The
cloudflaredservice is pinned to--protocol http2with explicit DNS resolvers (1.1.1.1,1.0.0.1) indocker-compose.production.yml. - This avoids environments where Docker's embedded resolver (
127.0.0.11) cannot resolveregion*.v2.argotunnel.com, which causes connector precheck failure and tunnel shutdown. - If tunnel status is still down, verify host/container egress for DNS and TCP 443 to
api.cloudflare.comand*.argotunnel.com.
5. Security notes
- Keep
postgresand other internal-only services off public hostnames unless required. - Use distinct hostnames per service; avoid path-based multiplexing for unrelated admin surfaces.
- Rotate
CLOUDFLARE_TUNNEL_TOKENand Access policy memberships on a regular schedule.