Skip to content

Add Caddy reverse proxy as an HTTPS-capable alternative to nginx#1236

Merged
bnmnetp merged 4 commits into
mainfrom
add-caddy-reverse-proxy
Jun 13, 2026
Merged

Add Caddy reverse proxy as an HTTPS-capable alternative to nginx#1236
bnmnetp merged 4 commits into
mainfrom
add-caddy-reverse-proxy

Conversation

@bnmnetp

@bnmnetp bnmnetp commented Jun 12, 2026

Copy link
Copy Markdown
Member

What

Adds a new projects/caddy/ reverse-proxy service, parallel to projects/nginx/, that replicates the routing in projects/nginx/runestone one-for-one but uses Caddy so HTTPS works with minimal hassle.

The goal: HTTPS locally in dev, and easy HTTPS for anyone running a single composed application, without the certbot dance.

How to try it

It's wired into compose as the caddy service. Set the listen address in .env:

CADDY_SITE_ADDRESS Behavior
unset / :80 HTTP only — parity with nginx
https://localhost local dev HTTPS via Caddy's internal CA
https://your.domain automatic Let's Encrypt cert

For https://localhost you'll get a browser warning until you trust Caddy's local root once — steps are in projects/caddy/README.md.

After editing .env: docker compose up -d caddy.

Notes for reviewers

  • /ns exclusion: nginx used a negative lookahead (?!ns/) to keep /ns/... out of the book-static file match. Go's RE2 engine has no lookahead, so this is reproduced via handler ordering (match /ns before the static handlers).
  • Upload limit: the 25 MiB body limit on /ns matches nginx byte-for-byte (Caddy's MB is decimal, so 25MiB is used, not 25MB).
  • Headers: X-Forwarded-Proto: https is forced on ns/assignment/admin/author; the catch-all to web2py uses the real scheme — same as the nginx config.
  • WebSockets, prefix-stripping (ns/assignment/admin stripped, author kept), and all three internal rewrites (ads.txt, JavaReview, csawesome) were verified end-to-end against live containers.
  • Caddy lives alongside nginx; they both want ports 80/443, so only run one at a time (profiles control which).

🤖 Generated with Claude Code

bnmnetp and others added 3 commits June 12, 2026 13:22
Adds a new projects/caddy/ service that mirrors the routing in
projects/nginx/runestone one-for-one, but uses Caddy so HTTPS works with
minimal hassle: automatic Let's Encrypt for a real domain, or a
locally-trusted cert for dev via CADDY_SITE_ADDRESS.

- projects/caddy/{Caddyfile,Dockerfile,README.md}: full routing + docs
- docker-compose.yml: caddy service (+ caddy_data/caddy_config volumes)
- sample.env: documented CADDY_SITE_ADDRESS knob

The /ns exclusion that nginx did with a negative lookahead (unsupported by
Go's RE2) is reproduced via handler ordering; the 25 MiB upload limit on
/ns matches nginx byte-for-byte. Verified all routes end-to-end against
live containers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 12, 2026 22:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Caddy-based reverse proxy as an HTTPS-capable alternative to the existing nginx reverse proxy, with compose wiring and documentation to support local HTTPS and public ACME certs.

Changes:

  • Added a new projects/caddy/ image (Dockerfile + Caddyfile) and user documentation for HTTPS setup.
  • Updated docker-compose.yml to introduce a caddy service (and moved nginx behind a compose profile) plus persisted Caddy state via named volumes.
  • Removed/pruned a set of legacy web2py controllers (including a large reduction of endpoints in ajax.py) and updated a StudyClues base-course mapping table.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sample.env Documents new CADDY_SITE_ADDRESS env var and expected behaviors.
projects/caddy/README.md Adds setup/troubleshooting docs for local/public HTTPS with Caddy.
projects/caddy/Dockerfile Defines the Caddy image and copies shared static assets for direct serving.
projects/caddy/Caddyfile Implements reverse-proxy routing intended to mirror the nginx routing behavior.
docker-compose.yml Adds caddy service + named volumes; puts nginx behind a compose profile.
bases/rsptx/web2py_server/applications/runestone/controllers/toctree.rst Removes controller docs toctree file.
bases/rsptx/web2py_server/applications/runestone/controllers/proxy.py Removes legacy proxy controller.
bases/rsptx/web2py_server/applications/runestone/controllers/exams.py Removes controller.
bases/rsptx/web2py_server/applications/runestone/controllers/designer.py Removes controller.
bases/rsptx/web2py_server/applications/runestone/controllers/books.py Removes controller.
bases/rsptx/web2py_server/applications/runestone/controllers/ajax.py Removes many deprecated endpoints; retains a small set of legacy endpoints.
bases/rsptx/assignment_server_api/routers/student.py Updates base-course → StudyClues book ID mappings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker-compose.yml
# For local HTTPS set CADDY_SITE_ADDRESS=https://localhost in your .env;
# for a public site set CADDY_SITE_ADDRESS=https://your.domain.
caddy:
# profiles: [ "caddy" ]
Comment thread projects/caddy/Dockerfile
# This image is an alternative to projects/nginx. It performs identical routing
# but uses Caddy so HTTPS works out of the box - automatic Let's Encrypt for a
# real domain, or a locally-trusted cert for dev. See projects/caddy/Caddyfile
# for the CADDY_SITE_ADDRESS / CADDY_ACME_EMAIL knobs.
Comment on lines +4 to +15
# **Most of this file is Deprecated.**
# The endpoints that used to live here have moved to the BookServer. Only the
# endpoints still required by the legacy web2py application remain:
#
# * ``set_tz_offset()`` -- records the browser timezone offset in the session
# (still posted to by some web2py views).
# * ``getassignmentgrade()`` -- returns a student's grade/comment for a question.
# * ``broadcast_code()`` -- lets an instructor share scratch ActiveCode with the
# whole class.
#
# If you are debugging browser-to-server API behavior you almost certainly want
# the BookServer, not this file.
@bnmnetp bnmnetp merged commit 4bb22fc into main Jun 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants