Skip to content

Secure reverse proxy with no open ports using Cloudflare Tunnels and Traefik. Perfect for self-hosting.

License

Notifications You must be signed in to change notification settings

huynhminhthien/cf-traefik

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 Cloudflare + Traefik: Zero-Exposure Proxy

Secure reverse proxy with no open ports using Cloudflare Tunnels and Traefik. Perfect for self-hosting.

🔥 Advance of this approach

  • 🚫 No open ports – All traffic flows through Cloudflare’s encrypted tunnels (no inbound firewall rules).
  • 🔒 Zero Trust ready – Origin server IP stays hidden; no direct internet exposure.
  • 🤖 Fully automated – Wildcard TLS certificates via Cloudflare DNS challenges.
  • 🚀 Production-optimized – TLS 1.3, security headers, and health checks
graph LR  
  A[User] -->|HTTPS| B[Cloudflare Edge]  
  B -->|QUIC Tunnel| C[cloudflared]  
  C -->|Internal HTTPS| D[Traefik]  
  D -->|HTTPS| E[Your Services]  
Loading

🚀 Quick Start

Prerequisites

Cloudflare account with a domain (example.com) Docker installed

Setup

  1. Clone the repo:
git clone https://github.com/huynhminhthien/cf-traefik.git
cd cf-traefik
  1. Configure environment:
cp .env.example .env  
# Edit .env with your Cloudflare API token, email, and domain  
  1. Deploy
./setup

Example configure when add new service

    labels:
      - "traefik.enable=true"
      # HTTP → HTTPS redirect
      - "traefik.http.routers.immich.entrypoints=web"
      - "traefik.http.routers.immich.rule=Host(`immich.example.com`)"
      - "traefik.http.middlewares.immich-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.immich.middlewares=immich-https-redirect"
      
      # HTTPS router
      - "traefik.http.routers.immich-secure.entrypoints=websecure"
      - "traefik.http.routers.immich-secure.rule=Host(`immich.example.com`)"
      - "traefik.http.routers.immich-secure.tls=true"
      - "traefik.http.routers.immich-secure.service=immich"
      
      # Backend config 
      - "traefik.http.services.immich.loadbalancer.server.scheme=http"
      - "traefik.http.services.immich.loadbalancer.server.port=2283"
      - "traefik.docker.network=proxy"
sequenceDiagram
    User->>Traefik: HTTP request (port 80)
    Traefik->>User: 301 Redirect to HTTPS
    User->>Traefik: HTTPS request (port 443)
    Traefik->>Immich: HTTP (port 2283, unencrypted)
    Immich->>Traefik: HTTP response
    Traefik->>User: HTTPS response
Loading

About

Secure reverse proxy with no open ports using Cloudflare Tunnels and Traefik. Perfect for self-hosting.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages