Skip to content

Add Caddy custom-domains deploy destination - #95

Merged
adriaandotcom merged 4 commits into
mainfrom
caddy
Oct 21, 2026
Merged

adriaandotcom merged 4 commits into
mainfrom
caddy

Conversation

@jimvandervoort

@jimvandervoort jimvandervoort commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Deployment target cleanup

Merge PR #119 into this PR first, then merge this PR into main. It removes the retired custom destination and its external-server upload path, leaving CDN and Caddy as the only deploy targets, both selected by default.

Summary

Closes #96

Adds a caddy deploy destination for the new Caddy-based custom-domains setup (see simpleanalytics/infrastructure#231, ansible/vars/apps/custom-domains.yml).

  • Uploads the same set of files as the old external nginx server (custom destination): latest/events/latest.dev, SRI v<n>/ files, light, proxy and auto-events, plus source maps.
  • Rewrites the nginx SSI directives to Caddy template placeholders on upload, because Caddy's templates directive substitutes the request hostname ({{.Req.Host}}) and the proxy-product hostname/path query parameters at serve time.
  • The caddy-ssi transform fails the deploy if a build contains stray {{ delimiters or an SSI directive without a known replacement, so a bad build cannot turn into per-request 500s.
  • Uploads go via a temporary file so the transformed bytes are what lands on esapp05, and post-upload verification compares against the transformed content.
  • pnpm deploy --caddy-only deploys exclusively to the new setup, leaving the CDN and the old external server untouched during the migration.

Follow-up

  • The "update https://docs.simpleanalytics.com/sri" reminder now only shows when the old custom destination is selected, since Caddy needs no nginx config change for a new SRI version. The docs update still applies to Caddy-only SRI deploys; worth splitting the reminder once the old server is gone.

Test plan

  • pnpm typecheck
  • pnpm test:deploy (17 pass, 5 new)
  • Dry run pnpm deploy --caddy-only and compare the preview against esapp05
  • Real --caddy-only deploy, then run verify-custom-domains-parity.sh / verify-proxy-parity.sh from elastic-infra

🤖 Generated with Claude Code

https://claude.ai/code/session_01ApznmYeffWY6YojKXhEJDW

Security implications

Has security impact - described as: This PR is labeled change: needs review, but Claude did not provide specific security implications. Reviewers should confirm the actual impact on security, privacy, customer/user data, system stability, or critical functionality.

Testing

Not run by Claude.

Checklist

  • Linked to an issue
  • Tested
  • Asked for a review

Add a "caddy" destination alongside "custom" for the new Caddy-based
custom-domains setup (elastic-infra ansible/vars/apps/custom-domains.yml).
It uploads the same files as the old external nginx server, but rewrites
the nginx SSI directives to Caddy template placeholders on upload, since
Caddy's templates directive injects the request hostname and the
proxy-product query parameters at serve time.

The caddy-ssi transform fails the deploy if a build contains stray Go
template delimiters or an SSI directive without a known replacement, so
a bad build cannot turn into per-request 500s. Uploads go via a temporary
file so the transformed bytes are what lands on the server, and the
post-upload verification compares against the transformed content.

A --caddy-only flag deploys exclusively to the new setup, leaving the CDN
and the old external server untouched during the migration.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ApznmYeffWY6YojKXhEJDW
Comment thread deploy.mts Outdated
@github-actions github-actions Bot added the change: needs review Changes affecting security, data protection, or system stability. label Sep 10, 2026
@github-actions

Copy link
Copy Markdown

SDLC label: change: needs review because it changes how the customer-facing scripts are transformed and served on the production custom-domains infrastructure.

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Claude review checkpoint

Reviewed commit 1350bc053c8faaa47ff4fd57d7a5c9d531255fc4. This is used to keep later automated reviews focused on changes Claude has not checked yet.

simple-analytics-ai Bot and others added 2 commits October 15, 2026 23:52
Co-authored-by: Simple Analytics Codex <codex@simpleanalytics.invalid>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: d408d0cb-ed50-45d1-bbae-680baf08293b
📥 Commits

Reviewing files that changed from the base of the PR and between af50ce1 and 1350bc0.

📒 Files selected for processing: 2
  • deploy.mts
  • test/deploy.test.mts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@adriaandotcom
adriaandotcom merged commit 4353f2f into main Oct 21, 2026
4 of 5 checks passed
@adriaandotcom
adriaandotcom deleted the caddy branch October 21, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change: needs review Changes affecting security, data protection, or system stability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy-product hostname and path values are injected unescaped into the served tracking script

2 participants