Repository navigation
Description
fix(docker): harden production docker-compose — remove direct backend port exposure and document TLS expectations
Symptom
The production deployment manifest (docker-compose.prod.yml) has two issues that affect every operator who deploys Rackscope using the published GHCR images:
-
The backend container is published on host port 8000, bypassing the frontend's reverse proxy. Any client that can reach the host network can call the API directly on port 8000, completely bypassing the security headers (HSTS, CSP, X-Frame-Options, etc.) set by the frontend's bundled nginx.
-
The production stack serves HTTP on port 80 only, with no TLS termination. The operator is implicitly expected to put a reverse proxy (Traefik, Caddy, cloud LB) in front, but this expectation is not stated anywhere — neither in the compose file nor in the deployment documentation. A naive operator running
docker compose -f docker-compose.prod.yml up -dexposes Rackscope to the network in clear HTTP.
Technical Analysis
Issue 1 — backend port exposure
# docker-compose.prod.yml:13-18
services:
backend:
image: ghcr.io/sckyzO/rackscope-backend:${RACKSCOPE_VERSION:-latest}
restart: unless-stopped
ports:
- "8000:8000" # ← exposes backend directly to the host
volumes:
- ./config:/app/configThe frontend image bundles its own nginx (frontend/nginx.prod.conf:17-24) which proxies /api/ to backend:8000 via the Docker internal network. The backend port mapping on the host is redundant and dangerous: it provides a second entry point that does not pass through nginx, hence does not benefit from:
X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 1; mode=blockReferrer-PolicyContent-Security-Policy
It also makes a future auth_basic or rate-limiting layer at the nginx level impossible to rely on, because the bypass channel is always open.
The internal healthcheck (healthcheck.test: ["CMD", "curl", "-f", "http://localhost:8000/healthz"] at line 30) runs inside the backend container, hitting localhost:8000. It does not require the port to be published on the host.
Issue 2 — implicit TLS expectation
# docker-compose.prod.yml:36-43
frontend:
image: ghcr.io/sckyzO/rackscope-frontend:${RACKSCOPE_VERSION:-latest}
restart: unless-stopped
ports:
- "80:80" # ← HTTP only
depends_on:
backend:
condition: service_healthyThe bundled nginx (frontend/nginx.prod.conf:2) listens on plain HTTP. The header Strict-Transport-Security is not set (the dev compose's nginx does set it, but the prod image's nginx does not). Some operators will deploy this directly on a public IP with no TLS proxy in front, and Rackscope will silently serve unencrypted traffic.
This is a documentation and discoverability problem, not a code defect — the design assumes upstream TLS termination, but does not communicate it.
Proposed Fix
Fix 1 — remove the direct backend port mapping
Edit docker-compose.prod.yml:
backend:
image: ghcr.io/sckyzO/rackscope-backend:${RACKSCOPE_VERSION:-latest}
restart: unless-stopped
- ports:
- - "8000:8000"
volumes:
- ./config:/app/configThe backend remains reachable from the frontend container via the Docker network (http://backend:8000 from inside frontend's nginx). External clients reach the API exclusively via http://<host>/api/... through the frontend's nginx proxy.
If an operator needs local debug access to the backend (rare), they can bind the port to localhost only by overriding in a docker-compose.override.yml:
services:
backend:
ports:
- "127.0.0.1:8000:8000"Document this escape hatch in the admin guide.
Fix 2 — make the TLS expectation explicit
Two changes:
A. Add a prominent comment block at the top of docker-compose.prod.yml explaining the deployment model:
# Rackscope — Production stack
#
# This stack assumes an upstream TLS-terminating reverse proxy
# (Traefik, Caddy, cloud LB, Cloudflare, ...) in front of the frontend container.
# The frontend serves HTTP on port 80 internally; the upstream proxy
# is expected to handle TLS, HSTS, and any organisation-specific access controls.
#
# DO NOT expose this stack directly on a public network without an upstream
# TLS proxy. See:
# - docs/admin-guide/deployment.md — full deployment guide
# - docs/admin-guide/reverse-proxy.md — Traefik / Caddy / nginx samples
#
# Usage:
# export RACKSCOPE_VERSION=1.0.0
# docker compose -f docker-compose.prod.yml up -dB. Add a new doc file rackscope_documentation/docs/admin-guide/reverse-proxy.md with three minimal-but-complete samples:
- Traefik v3 with Let's Encrypt — for self-hosted ops with a public IP
- Caddy 2 with automatic TLS — for the simplest setup
- nginx external — for organisations that already run nginx as their edge proxy
Each sample is a 20-line config that the operator can copy/paste and adapt.
C. Optional companion artifact (out of scope for this PR but recommended as a follow-up) — provide a docker-compose.prod-tls.yml bundled variant that includes Traefik with Let's Encrypt by default. Tracked separately if requested.
Test Checklist
Compose smoke tests (CI or local)
-
docker compose -f docker-compose.prod.yml configvalidates (no syntax error) -
docker compose -f docker-compose.prod.yml up -dbrings up backend and frontend -
curl -fsS http://localhost/api/healthzreturns 200 (via frontend nginx) -
curl -fsS http://localhost:8000/healthzfails to connect (port no longer bound — confirms fix 1) - Inside the
frontendcontainer,curl http://backend:8000/healthzstill returns 200 (internal network unaffected)
Documentation tests
-
docs/admin-guide/reverse-proxy.mdrenders cleanly (markdownlint) - The Traefik sample uses an explicit version pin
- The Caddy sample produces a valid
Caddyfile - The nginx sample includes
Strict-Transport-Securityand matches the security header set bundled infrontend/nginx.prod.conf(consistency between internal and external proxy chains)
Backwards-compat tests
- Existing healthcheck on the backend container still passes (
curl -f http://localhost:8000/healthzfrom inside the container) - No environment variable change required for existing deployments
- Operators currently relying on the published port 8000 see a clear comment in the migration notes pointing them at the localhost override pattern
Impact and Severity
- Audience affected: every production deployment that uses
docker-compose.prod.yml. Today's deployments have a redundant attack surface (port 8000 bypassing nginx) and may silently serve unencrypted HTTP. - Severity: medium-high. Direct port exposure compounds Issue A (fix(security): add require_admin to mutation endpoints in topology, catalog, and config routers #26 — missing
require_adminon mutations): without the port mapping fix, even addingrequire_adminleaves a parallel unprotected channel. HTTP-only operation is a documentation gap that causes silent insecure deployments. - Priority: ship as part of the v1.0.0 security hardening series, alongside Issue A (fix(security): add require_admin to mutation endpoints in topology, catalog, and config routers #26) and Issue D (fix(security): sanitize GET /api/config — exclude TLS file paths and add plugin sanitization contract #30).
Breaking Changes
Behavioural change for operators currently relying on http://<host>:8000/api/...:
- After this PR, the only way to reach the API is via
http://<host>/api/...(through the frontend nginx). - This is a tightening, not a contract break — the API URL
http://<host>/api/...was already documented and supported. - Operators who need port 8000 explicitly can opt back in via the documented override pattern.
Release notes must call out:
Production deployments: the backend container no longer publishes port 8000 on the host. The API remains available via the frontend reverse proxy (
http://<host>/api/...). If you previously hit port 8000 directly, switch to the frontend endpoint or add adocker-compose.override.ymlbinding the port to127.0.0.1only.
Related
- Audit ref: SEC-05, SEC-06 in
AUDIT_ARCHITECTURAL.md(new findings added during the production compose review) - Companion to Issue A (fix(security): add require_admin to mutation endpoints in topology, catalog, and config routers #26 — require_admin) and Issue D (fix(security): sanitize GET /api/config — exclude TLS file paths and add plugin sanitization contract #30 — config sanitization) in the v1.0.0 security hardening series
- Does not block or depend on Issues RBAC v1 — Phase 1: local-only authentication & authorization #25/fix(security): add require_admin to mutation endpoints in topology, catalog, and config routers #26/feat(auth): local RBAC backend — multi-user accounts with viewer/editor/admin roles #27/feat(auth): file-based API tokens for external integrations (NetBox, BlueBanquise) #28/feat(frontend): role-based access control UI — page guards, Users, API Tokens, Access Control #29 (RBAC initiative)
Out of Scope
- Bundling a Traefik+Let's Encrypt variant (
docker-compose.prod-tls.yml) — separate follow-up if requested - Adding TLS termination to the frontend image itself (would force every operator to manage certs in-container; the upstream-proxy model is intentionally simpler)
- Changing the dev compose (
docker-compose.dev.yml) — already has TLS via the nginx service, not affected
Activity