Last active 1 month ago

simple-windows-hosting.md Raw
  1. Get yr site files ready
mkdir C:\sites\skaia-library

Drop yr index.html in there.

  1. Install Caddy

Easiest is scoop install caddy with https://scoop.sh/, or grab the binary directly from caddyserver.com/download. No need for the caddy_windows_amd64.exe build with plugins.

  1. Caddyfile

Since Cloudflare Tunnel will handle the public-facing TLS, Caddy only needs to serve locally, so no need for its automatic HTTPS:

:8080 {
    root * C:\sites\skaia-library
    file_server
}

Run it from that directory: caddy run --config Caddyfile

  1. Install cloudflared

winget install --id Cloudflare.cloudflared -e (or grab the .exe from the cloudflared GitHub releases page).

  1. Authenticate

Run cloudflared tunnel login in the cmd.

This will pop up a browser window, log in and pick the zone (domain) you want to authorize.

  1. Create the tunnel

cloudflared tunnel create skaia-tunnel

This will generate a tunnel UUID and drops a credentials JSON in %USERPROFILE%\.cloudflared\.

  1. Route a hostname to it

cloudflared tunnel route dns mysite-tunnel sub.skaia-library.xyz

This will create the CNAME in Cloudflare DNS pointing at <UUID>.cfargotunnel.com.

  1. Create the config file at %USERPROFILE%\.cloudflared\config.yml:
yamltunnel: skaia-tunnel
credentials-file: C:\Users\YOURNAME\.cloudflared\<UUID>.json

ingress:
  - hostname: sub.skaia-library.xyz
    service: http://localhost:8080
  - service: http_status:404
  1. Run it!

cloudflared tunnel run skaia-tunnel

Site should now be live at sub.skaia-library.xyz, proxied through Cloudflare.

  1. Make it persistent

cloudflared service install registers cloudflared as a Windows service using that config.yml which means it'll survive reboots.

Caddy doesn't have a built-in Windows service installer, it will need to run with Task Scheduler at logon/startup, or use NSSM (nssm install caddy) to wrap it as a proper service. https://nssm.cc/