thermograph/deploy/Caddyfile
Emi Griffith 9d315f81c6 Caddyfile: redirect old raw-IP URLs to the canonical domain (#16)
Requests to http://<vps-ip>/... were bounced by the default HTTP->HTTPS rule to
https on the bare IP, which has no certificate and fails the TLS handshake, so
pre-domain bookmarks dead-ended with a blank page. Add an http://<ip> site block
that 301-redirects to https://emigriffith.dev, preserving the path.
2026-07-11 03:40:08 +00:00

47 lines
1.7 KiB
Caddyfile

# /etc/caddy/Caddyfile on the VPS.
# The domain's A/AAAA record must already point at this VPS — Caddy provisions a
# Let's Encrypt cert on first request and auto-renews. Nothing else to do for TLS
# (just make sure ports 80 and 443 are open).
#
# Layout on this domain:
# / -> static portfolio site (served straight from disk)
# /thermograph/* -> reverse-proxied to the Thermograph uvicorn (loopback)
#
# Thermograph must run with THERMOGRAPH_BASE=/thermograph (see /etc/thermograph.env)
# so the app serves itself under that prefix. The app no longer claims "/", so the
# root is free for the portfolio.
emigriffith.dev {
encode zstd gzip
# Thermograph — the app serves all pages, assets, and API under /thermograph.
# Match both the bare prefix and everything beneath it; the app redirects the
# bare /thermograph to /thermograph/.
@thermograph path /thermograph /thermograph/*
handle @thermograph {
reverse_proxy 127.0.0.1:8137
}
# Portfolio at the root. Point `root` at the built static site (for the Astro
# portfolio that's its `dist/` output). file_server serves index.html for
# directories and returns a real 404 for missing paths.
handle {
root * /var/www/emigriffith
file_server
}
log {
output file /var/log/caddy/emigriffith.log
}
}
# Old bookmarks to the raw IP (the pre-domain URL) would otherwise get bounced to
# HTTPS-on-the-IP, which has no cert and fails. Redirect them to the real domain.
http://75.119.132.91 {
redir https://emigriffith.dev{uri} permanent
}
# Optional: redirect www -> apex. Add a www CNAME/A record first, then uncomment.
# www.emigriffith.dev {
# redir https://emigriffith.dev{uri} permanent
# }