Files
stpweb/nginx/Dockerfile
adamfandClaude Code 03e10be2e4
Deploy with Docker Compose / deploy (push) Successful in 59s
Security audit fixes: JWT secret guard, WS revocation, nginx headers/TLS, loopback Gitea
- auth: panic at init if BACKEND_SECRET missing/short — HS256 would happily
  start with an empty key, making admin tokens forgeable by anyone
- websocket: admin check now goes through AuthenticateTokenWithClaims so the
  "tv" token-version revocation applies on /ws too; a logged-out or
  password-changed token no longer keeps it alive for its full lifetime
- admin diagnostics: check BACKEND_SECRET not the nonexistent AUTH_SECRET
- rowing upload: 10MB cap before buffering + base64 (admin-only route, but
  unbounded read = easy memory exhaustion + huge paid Claude call)
- nginx: shared security_headers.conf (XFO/nosniff/Referrer-Policy/HSTS/CSP)
  included in every location that sets its own add_header — nginx drops the
  parent's whole set otherwise; CSP added to the SPA document;
  ssl_protocols pinned to TLSv1.2/1.3; HSTS on apex redirect
- compose: Gitea HTTP bound to 127.0.0.1 (plain HTTP was LAN-exposed);
  autoheal docker socket mount read-only

Co-Authored-By: Claude Code <[email protected]>
2026-09-22 23:12:56 +01:00

42 lines
2.2 KiB
Docker

# =============================================================================
# nginx image — the public edge. Stock nginx plus two tools and three templates.
#
# BASE: nginx:1.27, pinned to a minor version. Official nginx images are
# multi-arch, so the same tag resolves to the arm64 build on the Raspberry Pi
# with no platform pin needed — that is why there is no `--platform` anywhere
# in this repo.
#
# WHY THE EXTRA PACKAGES
# gettext-base provides `envsubst`, which entrypoint.sh uses to render a
# config template. Not in the base image.
# openssl used by entrypoint.sh to mint the self-signed localhost
# certificate in DEV_MODE only. Installed unconditionally
# because there is one image for both dev and production.
#
# `rm -rf /etc/nginx/html/*` clears the stock "Welcome to nginx" page, since
# that directory is where the vue_dist volume gets mounted and a leftover
# index.html there would be served if the Vue build ever failed.
#
# apt lists are deleted in the SAME RUN layer so they never end up in the image.
#
# NO nginx.conf IS COPIED IN. All three templates (plus the dev partial) are,
# and entrypoint.sh picks one at container start. See nginx/entrypoint.sh for
# that decision.
# =============================================================================
FROM nginx:1.27
RUN rm -rf /etc/nginx/html/* && \
apt-get update && apt-get install -y gettext-base openssl && \
rm -rf /var/lib/apt/lists/*
COPY nginx.conf.template /etc/nginx/nginx.conf.template
COPY nginx_setup.conf.template /etc/nginx/nginx_setup.conf.template
COPY nginx_dev.conf.template /etc/nginx/nginx_dev.conf.template
# Shared body of the dev :80 and :443 server blocks. entrypoint.sh renders it
# (same envsubst allow-list) to /etc/nginx/nginx_dev_common.conf, which is the
# path both `include` directives in nginx_dev.conf.template point at.
COPY nginx_dev_common.conf.template /etc/nginx/nginx_dev_common.conf.template
# Static security-header include, referenced from nginx.conf.template (and
# any location that sets its own add_header). Not templated — no envsubst.
COPY security_headers.conf /etc/nginx/security_headers.conf
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]