Files
ansible/roles/docker/templates/Caddyfile.j2
T
PhilandClaude Opus 5.5 30bc0a46b4 caddy: access logs, security headers; dns: CAA records
- (logging) snippet: JSON access log at /data/logs/access.log, rotated,
  tokens/OIDC codes and API key headers masked
- (security_headers)/(no_framing): nosniff, Referrer-Policy and
  X-Frame-Options only where the app sets none; drop Server/X-Powered-By
- (static_site): adds a CSP (base-uri, object-src, frame-ancestors,
  form-action) and Permissions-Policy to the four static sites
- CAA records: Let's Encrypt + ZeroSSL on both domains, Amazon on
  thesatelliteoflove.com for links. (CloudFront/ACM), no wildcards

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 11:52:22 -07:00

242 lines
6.4 KiB
Caddyfile

# Tell browsers to always use HTTPS for each site for a year. No
# includeSubDomains, so hosts not served here are unaffected.
# defer: replace any HSTS header an app sends itself, so there's only one.
(hsts) {
header {
Strict-Transport-Security "max-age=31536000"
defer
}
}
# JSON access log shared by every site, in the caddy_data volume
# (/data/logs). Read by humans and, later, CrowdSec. Caddy already redacts
# Cookie/Authorization headers; the filter also masks ?token= (Gotify clients
# put their app token in the query string).
(logging) {
log {
output file /data/logs/access.log {
roll_size 50MiB
roll_keep 10
roll_keep_for 720h
}
format filter {
request>uri query {
replace token REDACTED
replace access_token REDACTED
replace code REDACTED
}
request>headers>X-Gotify-Key replace REDACTED
request>headers>X-Api-Key replace REDACTED
}
}
}
# Headers for proxied apps. "?" only sets a header the app didn't send, so
# apps with their own (stricter) values keep them. Server/X-Powered-By are
# dropped so responses don't advertise software versions.
(security_headers) {
header {
?X-Content-Type-Options nosniff
?Referrer-Policy strict-origin-when-cross-origin
-Server
-X-Powered-By
}
}
# Refuse to be framed by other sites (clickjacking). Not for apps that are
# meant to be embedded elsewhere (HeyForm forms).
(no_framing) {
header ?X-Frame-Options SAMEORIGIN
}
# Static sites: everything above plus a CSP. No default-src so existing
# scripts, styles and images keep working; it blocks plugins, <base>
# hijacking, framing and forms posting off-site.
(static_site) {
import logging
import hsts
import security_headers
header {
Content-Security-Policy "base-uri 'self'; object-src 'none'; frame-ancestors 'self'; form-action 'self'"
X-Frame-Options SAMEORIGIN
Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=()"
}
}
# Every proxied site: log, HSTS and the shared headers.
(site) {
import logging
import hsts
import security_headers
}
{{ subdomains.pocketid }} {
import site
import no_framing
reverse_proxy pocket-id:1411
}
paper.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy paperlessngx-webserver-1:8000
}
cal.thesatelliteoflove.com {
import site
import no_framing
redir /.well-known/caldav /dav.php 302
redir /.well-known/carddav /dav.php 302
reverse_proxy baikal-baikal-1:80
}
{{ subdomains.books }} {
import site
import no_framing
reverse_proxy kavita:5000
}
audio.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy audiobookshelf-audiobookshelf-1:80
}
loclog.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy dawarich_app:3000
}
watcher.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy changedetection:5000
}
snippets.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy bytestash:5000
}
git.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy gitea:3000
}
thesatelliteoflove.com {
import static_site
# WebFinger for phil@ serves two readers: the fediverse (GoToSocial's account
# domain is this apex) and Tailscale, which finds the tailnet's login
# provider through the OpenID issuer link.
# Answered for every query: Tailscale's lookup doesn't always send
# resource=acct:phil@..., and phil is the only account here anyway.
@webfinger_phil path /.well-known/webfinger
route {
header @webfinger_phil Content-Type application/jrd+json
header @webfinger_phil Access-Control-Allow-Origin *
respond @webfinger_phil `{"subject":"acct:phil@{{ primary_domain }}","aliases":["https://{{ subdomains.social }}/users/phil","https://{{ subdomains.social }}/@phil"],"links":[{"rel":"http://openid.net/specs/connect/1.0/issuer","href":"https://{{ subdomains.pocketid }}"},{"rel":"http://webfinger.net/rel/profile-page","type":"text/html","href":"https://{{ subdomains.social }}/@phil"},{"rel":"self","type":"application/activity+json","href":"https://{{ subdomains.social }}/users/phil"}]}` 200
# Other fediverse discovery goes to GoToSocial.
redir /.well-known/host-meta* https://{{ subdomains.social }}{uri} 301
redir /.well-known/nodeinfo https://{{ subdomains.social }}{uri} 301
}
root * /srv/tsol
file_server
}
bookmarks.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy hoarder-web-1:3000
}
social.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy gotosocial:8080
}
models.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy manyfold-app-1:3214
}
gotify.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy gotify:80
}
gotify-assistant.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy igotify-assistant:8080
}
pdg.thesatelliteoflove.com {
import static_site
root * /srv/pdg
# "{path}/" keeps the /dir -> /dir/ redirect; "{path}/index.html" is
# needed for "/" itself, which "{path}/" never matches in Caddy 2.11.
try_files {path} {path}.html {path}/ {path}/index.html =404
file_server
encode gzip
handle_errors {
rewrite * /{err.status_code}.html
file_server
}
}
starpunk.thesatelliteoflove.com {
import site
import no_framing
# MCP endpoint and its OAuth protected resource metadata (StarPunk v2.15.0)
@mcp path /mcp /mcp/* /.well-known/oauth-protected-resource /.well-known/oauth-protected-resource/*
handle @mcp {
reverse_proxy starpunk-mcp:8001
}
handle {
reverse_proxy starpunk:8000
}
}
repair.nerder.land {
import static_site
root * /srv/repair
file_server
}
nerder.land {
import static_site
root * /srv/nerderland
file_server
}
forms.nerder.land {
import site
reverse_proxy heyform-heyform-1:9157
}
listmonk.nerder.land {
import site
import no_framing
reverse_proxy listmonk:9000
}
repaircafe.nerder.land {
import site
redir /volunteer-signup https://listmonk.nerder.land/subscription/form 301
}
gokapi.thesatelliteoflove.com {
import site
import no_framing
reverse_proxy gokapi:53842
}