This deployment is designed for a hostile public internet environment. We assume:
- Perimeter Scans: Automated bots will scan ports 80/443 continuously.
- Credential Stuffing: Attackers will attempt to use breached credentials.
- Container Breakout: A theoretical risk we mitigate via hardening.
We use Docker network isolation to create "air gaps":
- Ingress Layer: Handles TLS termination and request validation.
- Data Layer:
internal: trueflag prevents the Database and Redis from accessing the internet.
- No New Privileges:
security_opt: [no-new-privileges:true]is set on ALL containers. This prevents a compromised process from gaining more privileges (e.g., viasudoor setuid binaries) even if the user is root inside the container. - ReadOnly Mounts: Sensitive directories are mounted read-only where applicable. The ingress proxy has no direct filesystem access to Nextcloud application or data files.
The bundled Caddy configuration enforces:
- HSTS Preload: Forces browsers to use HTTPS for the domain.
- Permissions Policy: Disables browser API features (Camera, Mic) unless explicitly trusted.
- Path Traversal Blocking: Explicit denial of hidden paths like
/.git,/build, or sensitive Nextcloud data.
- Account Security: The setup mandates strong admin passwords during initialization.
- Brute Force Protection: Nextcloud's built-in throttling is effective when configured with Redis (included).
Secrets (DB passwords, Redis passwords) are injected via a .env file at runtime.
- Risk Profile: Acceptable for single-tenant VPS where file permissions (
600on.env) are strictly enforced. - Mitigation: The
.envfile is excluded from git (.gitignore). - Future Path: For multi-node swarms, migration to Docker Secrets (mounted as files in
/run/secrets) is the standard upgrade path.
Note: Redis authentication is configured via command-line arguments, which may be visible via container inspection. This is acceptable for a single-tenant VPS but would be replaced with file-based secrets in multi-tenant environments.