# Caddy in front of Ghost on an exe.dev VM. From https://exe.dev/deploy/ghost # exe.dev's proxy terminates TLS and forwards https://.exe.xyz/ here. { auto_https off servers { # Keep exe.dev's X-Forwarded-Proto: https, so Ghost doesn't loop # redirecting to https. Only exe.dev's proxy reaches port 8000. trusted_proxies static 0.0.0.0/0 ::/0 } } :8000 { log { output stdout format console } encode gzip # Social web (ActivityPub): Ghost's hosted service by default @activitypub path /.ghost/activitypub/* /.well-known/webfinger /.well-known/nodeinfo handle @activitypub { reverse_proxy {$ACTIVITYPUB_TARGET} } # The parts of /ghost that are public on every Ghost site: the Content # API (search, Portal), the site summary and the staff token keys that # the social web service checks. @public_ghost path /ghost/api/content/* /ghost/api/admin/site/ /ghost/.well-known/* handle @public_ghost { reverse_proxy ghost:2368 } # Comments on posts look for a staff session here; answer visitors as # Ghost does when there is none, without sending them to sign in. @auth_frame { path /ghost/auth-frame /ghost/auth-frame/* not { import staff-emails } } handle @auth_frame { respond 204 } # Everything else under /ghost is Ghost Admin and its API: exe.dev # sign-in first, then only the accounts in staff-emails. @anonymous { path /ghost /ghost/* not header X-ExeDev-Email * } handle @anonymous { header Cache-Control no-store redir * /__exe.dev/login?redirect={path} 302 } @stranger { path /ghost /ghost/* not { import staff-emails } } handle @stranger { header Cache-Control no-store respond "{header.X-ExeDev-Email} can't open Ghost Admin on this site. The owner can add it to ~/ghost/caddy/staff-emails on the VM." 403 } handle { reverse_proxy ghost:2368 } }