Consider Caddy as the campus-gateway implementation (post-#995 simplification)

Open
#1,025 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
docker

Research direction

Start with deploy/gateway/README.md and the gateway setup under deploy/gateway/, then compare the proposed Caddyfile behavior with the current nginx configuration. Verify upstream resolution across a backend redeploy and confirm X-Forwarded-* headers reach the backends. Done means the gateway replacement passes the full smoke checklist from #995.

Written by the indexing model from the issue text.

Description

deployment

Description

The unified-hostname gateway (issue #995) is live on dev as an nginx container (deploy/gateway/, PRs #997–#1017, #1022, #1023). It works and is smoke-green, but nginx on Railway dragged us through a long tail of platform-specific sharp edges. This issue proposes Caddy as a simpler long-term implementation, to be considered as a follow-up — not as an urgent swap.

Use case

Sharp edges the current nginx setup needs that Caddy removes:

  • envsubst templating + snapshot workarounds — Railway's incremental snapshot builder once patch-merged a renamed template into a garbled hybrid; the Dockerfile now rms stock templates and uses a unique filename to force wholesale copies. Caddy is configured by a single static Caddyfile.
  • Resolver bracketing — Railway's mesh DNS is a bare IPv6 literal (fd12::10), which nginx misparses; we lean on the stock 15-local-resolvers.envsh mechanism to get bracketed addresses for the resolver directive. Caddy uses the system resolver directly and handles IPv6 nameservers natively.
  • Entrypoint semantics — nginx image exec-bit-first *.sh/*.envsh rules (child process vs sourced) cost us two deploy crashes. Caddy has no entrypoint scripting layer.

Proposed sketch

FROM public.ecr.aws/docker/library/caddy:2-alpine
COPY Caddyfile /etc/caddy/Caddyfile
:8080 {
    auto_https off                      # Railway edge already terminates TLS
    handle /auth/*         { reverse_proxy campus-auth.railway.internal:8080 }
    handle /integrations/* { reverse_proxy campus-auth.railway.internal:8080 }
    handle /api/*          { reverse_proxy campus-api.railway.internal:8080 }
    handle /audit/*        { reverse_proxy campusaudit.railway.internal:8080 }
    handle /health         { respond "ok" 200 }
    handle                 { redir /audit/ 302 }
}

(Docker Hub base images rate-limited our builds on 2026-10-30 — use the ECR public mirror or a digest pin.)

Caveats

  • Upstream re-resolution: static upstream hostnames resolve once at startup; Caddy 2.7+ dynamic a { name ... port ... refresh 10s } restores per-request-style resolution. In practice the per-service mesh endpoint IPs have been stable across redeploys (the fabric routes the stable service address to the live instance), so startup resolution likely suffices — verify against campus-auth/campus-api/campusaudit.railway.internal behavior on a backend redeploy.
  • X-Forwarded-*: the Caddyfile above must forward X-Forwarded-For/Proto/Host (nginx does this today; backends' ProxyFix depends on it). Defaults need checking.
  • What this does NOT fix: the one production failure we hit — a gateway instance with a broken mesh attachment (silent upstream hangs) — is Railway-side and would affect any proxy identically. The runbook stays: redeploy the gateway first, then investigate (see the railway-ops skill).
  • Swap cost: one worktree PR + the full smoke checklist from #995 re-run.

Alternatives considered

  • Keep nginx (default until this issue is picked up) — battle-tested through the chase, config is final and documented.
  • HAProxy — best runtime-DNS story (resolvers + hold valid), most arcane config.
  • Traefik — no advantage over Caddy here.
  • No gateway at all — cookie-scoped subdomains (auth./api./audit.campus.nyjc.app, already the prod BASE_URLS shape) with cookies on the shared parent domain would remove the gateway permanently, at the cost of redesigning the #995 cutover.

References

  • #995 (single-hostname cutover, anchor issue) · deploy/gateway/README.md · docs/railway-architecture.md · .zcode/skills/railway-ops
Dominant language
Python
Stars
0
Forks
2
Avg merge
39m
Merged PRs (30d)
235

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nyjc-computing/campus

All issues in nyjc-computing/campus

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.