Files
OpenVPN-Monitoring-Simple/DOCS/Deployment/Containers/Reference.md
T
ayurishchevandClaude Sonnet 5.5 ad6995bb63 Docs restructure, code review, gatherer reliability, JWT key fail-closed
Documentation
- Three levels: DOCS/General (overview, configuration), DOCS/Deployment
  (choose a method, first steps), details per method in Containers/ and
  System_Services/; new root README and DOCS/README map.
- Remove superseded pages (Deployment.md, Deployment_Docker/Native.md, Index.md);
  split the two scenario guides by section.
- Isolate the Timeweb/Hysteria2 records in DEPLOYMENTS/timeweb-hysteria2/
  (not linked from DOCS, listed in .graphifyignore).
- Add DOCS/code_review/ with a time-stamped analysis of the code base.

Gatherer (BUG-02, BUG-03)
- Session key (CN, address, connected_since_ts), baseline from the
  active_sessions snapshot, grace period for sessions missing from the status.
- Status file integrity (TITLE/TIME/END) and freshness; a torn read skips the tick.
- Cache applied after commit; main loop survives exceptions, backs off, and
  stops cleanly on SIGTERM/SIGINT; new client rows start with the first
  frame's totals; five tests.

JWT signing key (SEC-01)
- No built-in default: Core and Profiler refuse to start with a missing,
  placeholder or short (< 32) key; shipped config.ini has an empty value.
- Same rule in install.sh, update.sh (issues a new key when missing or weak),
  docker lib/entrypoint; five tests, conftest.py for the test key.

Each change has a plan and a summary under DOCS/Changes/.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-05 20:30:45 +03:00

4.7 KiB

Containers: reference

Configuration (.env), ports and volumes of the container installation. Install: Containers.

.env reference

Variable Required Default Meaning
JWT_SECRET yes none (compose refuses to start) Signing key of both APIs (OVPMON_API_SECRET_KEY). At least 32 characters, no change-me/changeme: install.sh, update.sh and the all-in-one container refuse a weak value. Changing it logs every user out. Keep the same value across updates
OVPMON_INITIAL_ADMIN_USER, OVPMON_INITIAL_ADMIN_PASSWORD first start only empty Seed for the first user, used only while the users table is empty. Removed by install.sh afterwards
OVPMON_CORS_ORIGINS no empty (off) Comma-separated extra origins; the UI is same-origin behind nginx
OVPMON_HTTP_PORT no 80 Host port of the UI
OVPMON_VPN_PORT no 1194 Host UDP port of OpenVPN (the container side is always 1194)

Variables of the scripts (environment of the shell, not .env): OVPMON_BACKUP_DIR (backup root, default ./backups), OVPMON_BACKUP_IMAGE (helper image, default alpine:3), OVPMON_HEALTH_TIMEOUT (seconds, default 180), OVPMON_MIN_FREE_MB (docker data, default 2048), OVPMON_MIN_FREE_BACKUP_MB (backups, default 1024).

OVPMON_VPN_PORT changes only the host side of the mapping. If you change the OpenVPN port in the server settings of the UI, the client profiles carry that port; keep the two consistent.

Ports

Port Published Purpose
${OVPMON_HTTP_PORT:-80}/tcp yes UI and reverse proxy to both APIs (plain HTTP)
${OVPMON_VPN_PORT:-1194}/udp yes OpenVPN
5001 (monitoring API), 8000 (profiler API) no variant B: exposed on ovp-net only; variant A: listen on 127.0.0.1 inside the container

Volumes: what is stored where

Volume Path in the container Content Mounted by (B)
ovp_logs /var/log/openvpn openvpn-status.log and OpenVPN logs gatherer, profiler
ovp_config /etc/openvpn server.conf generated by the profiler profiler
ovp_pki /app/easy-rsa easy-rsa scripts and pki/ (CA, server and client keys and certificates, CRL, ta.key, dh.pem) profiler
ovp_client_config /app/client-config generated client .ovpn files profiler
db_data /app/db ovpn_profiler.db, openvpn_monitor.db, migration backups *.db.bak-* gatherer, api, profiler

Not stored in volumes (lost when the container is recreated): the container file system, profiler.log and openvpn_gatherer.log (written into the working directory), supervisor state. Application logs go to docker logs.

Volume names are <project>_<volume>; the scripts find them by the compose labels, so any project name works.

Layout of variant A

The code is in /app/APP_CORE and /app/APP_PROFILER; the volumes are mounted at the same paths as in variant B (/app/db, /app/easy-rsa, /app/client-config, /etc/openvpn, /var/log/openvpn).

The profiler resolves easy-rsa/ and client-config/ relative to its working directory (services/pki.py, routers/profiles.py), and stores client-config/<name>.ovpn as a relative path in its database. In variant B that directory is /app. Variant A keeps it that way: supervisord starts the profiler with working directory /app (uvicorn --app-dir /app/APP_PROFILER main:app), so /app/easy-rsa and /app/client-config are the volumes. No symlinks are used, and the database paths are identical in both variants (so a volume set can be used by either variant). The monitoring API and the gatherer run with working directory /app/APP_CORE, where config.ini lives; their database path comes from OVPMON_OPENVPN_MONITOR_DB_PATH=/app/db/openvpn_monitor.db.

Processes in ovp-allinone (deploy/allinone/supervisord.conf, started in this order, all with autorestart, logs to stdout/stderr): gatherer, api (gunicorn -w 2 -b 127.0.0.1:5001 openvpn_api_v3:app), profiler (uvicorn on 127.0.0.1:8000, no reload), nginx. OpenVPN is started by the profiler API on request (direct start inside containers), as in variant B.

deploy/allinone/entrypoint.sh runs before supervisord: secret mapping (JWT_SECRET → OVPMON_API_SECRET_KEY when only the first is set), /dev/net/tun, easy-rsa workspace (copied only when the volume does not have it yet), NAT and MSS rules without duplicates, the nginx configuration rendered from APP_UI/default.conf.template for 127.0.0.1, then the database migration as an explicit step: the container does not start if it fails. The services then run with OVPMON_AUTO_MIGRATE=0 (they only verify the schema).