Files
OpenVPN-Monitoring-Simple/DOCS/Deployment/System_Services/Reference.md
T
ayurishchevandClaude Sonnet 5.5 3fac8d70d8 Deploy scripts: compose version check, ovpmon_backup.db in native backups
Docker: variant B needs Docker Compose 2.17+ (additional_contexts); install.sh
and update.sh check it in the preflight. Native: backup.sh, update.sh,
restore.sh and --rollback now copy and restore ovpmon_backup.db (Backup and
Restore settings) as an optional file. Verified install, update, backup,
restore and rollback on Debian 12 (systemd), Alpine 3.23 (OpenRC) and both
container variants.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-07 12:58:42 +03:00

7.7 KiB

System services: reference

Paths and owners, the environment file, the root helper configuration and security notes. Install: System services.

Layout: what is where, who owns it

Item Path Owner, mode
Code <prefix>/APP_CORE, <prefix>/APP_PROFILER root:root, read-only for others
Virtualenvs <prefix>/APP_CORE/venv, <prefix>/APP_PROFILER/venv root:root
PKI (CA, keys, certificates, CRL) <prefix>/APP_PROFILER/easy-rsa (real directory) ovpmon:ovpmon 750
Client profiles <prefix>/APP_PROFILER/client-config (real directory) ovpmon:ovpmon 750
Profiler log <prefix>/APP_PROFILER/profiler.log ovpmon:ovpmon 640
Shipped settings file <prefix>/APP_CORE/config.ini, <prefix>/APP_PROFILER/config.ini root:root; the environment file overrides it
Databases /var/lib/ovpmon/openvpn_monitor.db, ovpn_profiler.db, migration copies *.db.bak-* ovpmon:ovpmon
Local backup packages (Backup and Restore page), ovpmon_backup.db /var/lib/ovpmon/backups/ (created by the service, folders 700, files 600; root set by OVPMON_BACKUP_LOCAL_ROOT), /var/lib/ovpmon/ovpmon_backup.db (included in the host backup as db/backupcfg.db; the packages folder is not) ovpmon:ovpmon
Staging of server.conf /var/lib/ovpmon/staging/ ovpmon:ovpmon 750
Service environment /etc/ovpmon/env root:root 600
Helper configuration /etc/ovpmon/helper.conf root:root 644
TLS certificate and key /etc/ovpmon/tls/ovpmon.crt, ovpmon.key root:root (key 600)
Deployment state /etc/ovpmon/deploy.state root:root 644
nftables ruleset of the VPN clients (only after firewall.sh) /etc/ovpmon/nftables.nft, service ovpmon-nft root:root 644
Root helper /usr/local/sbin/ovpmon-helper root:root 755
doas rules Alpine: /etc/doas.d/ovpmon.conf; Debian/Ubuntu: block in /etc/doas.conf root:root
OpenVPN configuration /etc/openvpn/server.conf (Alpine) or /etc/openvpn/server/server.conf, /etc/openvpn/crl.pem, /etc/openvpn/scripts/ root:root
OpenVPN logs /var/log/openvpn/openvpn.log, openvpn-status.log (root:ovpmon 640) root
Service logs /var/log/ovpmon/ (OpenRC) or the journal (systemd) ovpmon / systemd
UI files /var/www/ovpmon root:root
Backups /var/backups/ovpmon/<UTC timestamp>/ root:root 700
Deployment log /var/log/ovpmon-deploy.log root:root 600

The profiler resolves easy-rsa/ and client-config/ relative to its working directory (APP_PROFILER) and keeps client-config/<name>.ovpn as a relative path in its database; therefore both are real directories inside APP_PROFILER (a symlinked client-config breaks the real-path checks and the clear_pki cleanup).

Environment file and helper configuration

/etc/ovpmon/env (root:root 600) is read by the init system as root and handed to the services. Lines are KEY=VALUE without quotes or spaces (systemd and OpenRC read the same file).

Variable Default written by install.sh Meaning
OVPMON_API_SECRET_KEY random, 64 hex characters signing key of both APIs; at least 32 characters, no change-me/changeme (the APIs refuse to start otherwise); changing it logs everybody out; keep it across updates. update.sh issues a new random key when it is missing or weak and resets all sessions
OVPMON_API_HOST, OVPMON_API_PORT 127.0.0.1, 5001 informational: gunicorn is started with -b 127.0.0.1:5001
OVPMON_OPENVPN_MONITOR_DB_PATH /var/lib/ovpmon/openvpn_monitor.db monitoring database
OVPMON_PROFILER_DB_PATH /var/lib/ovpmon/ovpn_profiler.db profiler database
OVPMON_OPENVPN_MONITOR_LOG_PATH /var/log/openvpn/openvpn-status.log status log read by the gatherer
OVPMON_LOGGING_LEVEL INFO
OVPMON_CORS_ORIGINS https://<host>:<https-port> extra allowed origin (the UI is same-origin behind nginx)
OVPMON_RUNTIME host forces host mode (never "container"), needed when the host itself runs inside a container
OVPMON_OPENVPN_SERVICE openvpn (Alpine) / openvpn-server@server service name for the root (non-helper) path
OVPMON_OPENVPN_CONFIG /etc/openvpn/server.conf / /etc/openvpn/server/server.conf server config path for the root (non-helper) path
OVPMON_INITIAL_ADMIN_USER, OVPMON_INITIAL_ADMIN_PASSWORD generated seed, only while the users table is empty; removed by install.sh after the first start
OVPMON_AUTO_MIGRATE unset 0 makes the services refuse to start while migrations are pending

With the unprivileged profiler the API only stages server.conf; the helper configuration decides where it is installed and which service is controlled.

/etc/ovpmon/helper.conf (INI, section [helper], root:root, not group/world writable, otherwise the helper refuses to run). Without the file the helper uses the built-in values of the Alpine layout.

Key Alpine (written) Debian/Ubuntu (written) Rule
install_dir /opt/OpenVPN-Monitoring-Simple same absolute, no ..; the PKI is <install_dir>/APP_PROFILER/easy-rsa/pki
service_manager openrc systemd openrc or systemd
service_unit openvpn openvpn-server@server ^[A-Za-z0-9@._-]{1,64}$, not starting with - or .
config_path /etc/openvpn/server.conf /etc/openvpn/server/server.conf absolute, below /etc/openvpn/, ends with .conf
staged_path /var/lib/ovpmon/staging/server.conf same absolute, below /var/lib/ovpmon/

OpenRC runs /sbin/rc-service <unit> <action>, systemd runs systemctl <action> <unit> (fixed argument list, fixed PATH). Unknown keys or invalid values make the helper refuse.

Security notes

  • Services run as ovpmon (no login shell); code and virtualenvs are root-owned and read-only for them. systemd units add PrivateTmp, ProtectHome, ProtectSystem=full, kernel and cgroup protection; ovpmon-api and ovpmon-gatherer also set NoNewPrivileges. ovpmon-profiler must not (it calls the setuid doas), must not use seccomp-based options either (ProtectKernelTunables, ProtectKernelModules, RestrictRealtime, LockPersonality, SystemCallFilter, ...): for an unprivileged unit systemd then sets NoNewPrivileges implicitly and doas fails with "not installed setuid" (check: grep NoNewPrivs /proc/<main pid>/status must show 0). It keeps /etc/openvpn writable, because the helper runs inside the profiler's mount namespace.
  • The helper accepts six fixed commands, validates server.conf against an allowlist and reads its own root-owned configuration; nothing else runs as root. ovpmon owns the PKI including the CA key: a compromised profiler can issue client certificates (VPN access) but cannot become root.
  • /etc/ovpmon/env is root:root 600 and never printed; the generated administrator password is shown once and removed from the file after the first start.
  • Backups contain private keys, password hashes and the secret: mode 700/600, keep off-host copies encrypted.
  • Both APIs listen on 127.0.0.1; only nginx (HTTPS) and OpenVPN are reachable. Replace the self-signed certificate when a domain is available; consider restricting the UI by address or reaching it through the VPN.
  • The scripts do not harden SSH or install fail2ban: see Host hardening.

Related: Database migrations, Privilege separation, Containers, Deployment plan.