Reverse proxy

HTTPS with Caddy

Keep Trestle on loopback and let Caddy own public TLS. Trust only the loopback address that actually connects to Trestle.

trestle.example.com {
  reverse_proxy 127.0.0.1:8090
}
TRESTLE_LISTEN=127.0.0.1:8090
TRESTLE_TRUSTED_PROXIES=127.0.0.1/32

Required behavior

  • Caddy must replace, not append untrusted, X-Forwarded-For and X-Forwarded-Proto values.
  • Do not trust broad private ranges unless every address in that range is an administered proxy.
  • Leave buffering disabled for /api/v1/realtime so SSE events stream promptly.
  • Set request limits large enough for configured uploads while retaining Trestle's own endpoint limits.
  • Preserve Host so strict origin and CSRF checks match the browser origin.
  • Webhook callbacks and Lambda invocation are outbound and require working DNS and HTTPS egress.

Smoke test

curl -fsS https://trestle.example.com/system/health
curl -fsS https://trestle.example.com/system/version