infrastructure/server_nas16.md

25 KiB
Raw Blame History

NAS16 --- LAMP Stack & Database Server

Device Type: Raspberry Pi
Hostname: NAS16
IP Address: 192.168.150.40
VLAN: 50 --- Lab / Servers

Last Updated: 2026-10-11


🧩 Role & Purpose

NAS16 is the dedicated LAMP stack, database, application-hosting, and administrative server for the KingDezigns network.

It runs OpenMediaVault as its base operating system and provides:

  • Apache web hosting
  • MariaDB services
  • PHP applications
  • Webmin administration
  • CrowdSec notification scripts
  • Forgejo
  • Fund Tracker
  • Debt Eliminator
  • Umami (web analytics)
  • Network and application backup scripts

NAS16 is located entirely within VLAN 50 and is protected by the VLAN's containment and firewall policies.


🖥️ Hardware

  • Raspberry Pi
  • SSD storage
  • Gigabit Ethernet

Drive Inventory

Device Model Capacity Role


/dev/sda Unknown ~256 GB OS/system drive

Drive model should be confirmed during a future hardware inventory update.


🌐 Network Placement

  • VLAN: 50 --- Lab / Servers
  • IP: 192.168.150.40
  • Access: LAN / cable

NAS16 must remain reachable from:

  • Trusted administrative devices
  • VLAN 50 services
  • Home Assistant Server/NPM for reverse-proxy traffic
  • Required internal Docker networks

📦 Primary Functions

Core Services

  • OpenMediaVault
  • Apache
  • MariaDB
  • PHP
  • Webmin
  • nginx as part of the OMV management stack

Additional Roles

  • CrowdSec external notification handler
  • Forgejo
  • Fund Tracker
  • Debt Eliminator
  • Umami (web analytics)
  • NAS08 → NAS16 rsync destination
  • NAS16 system/application backup operations

🌍 External Access Architecture

Public web traffic follows:

Internet
    ↓
NPM on Home Assistant Server
    ↓
NAS16
    ↓
Application service

Real client IP information is forwarded through X-Forwarded-For.

NAS16's nginx and Apache configurations are responsible for extracting the real client IP so backend security tools such as Fail2Ban do not treat HAS as the attacker.


🔧 Fail2Ban / Real IP

Fail2Ban is active on NAS16.

The proxy IP is trusted so that NPM traffic cannot cause HAS itself to be banned.

The current documented ignoreip pattern includes:

127.0.0.1/8
::1
192.168.150.0/24

Real IP forwarding remains required for public services behind NPM.


🔧 Forgejo

NAS16 hosts Forgejo as a Docker service.

  • Internal web UI: http://192.168.150.40:3000
  • Public URL: https://forgejo.kingdezigns.com/
  • Git SSH: LAN-only on port 2222
  • SQLite database
  • Data path: /opt/forgejo/data

Full Forgejo configuration is maintained in server_forgejo.md.


📈 Fund Tracker

NAS16 hosts Fund Tracker.

  • Production port: 8000
  • Public URL: https://funds.kingdezigns.com/
  • FastAPI + PostgreSQL
  • Independent QA/Production environments
  • Application-specific details: server_fundtracker.md

📊 Umami Analytics

NAS16 hosts Umami (self-hosted, cookie-free web analytics) as two Docker containers.

  • Project: umami at /Kingdezignsnas16/umami/ (OMV Compose)
  • Containers: umami (host port 3001), umami_db (Postgres 16, internal)
  • Public URL: https://stats.cutthecard.net/ (NPM on HAS, Force SSL)
  • Data: /opt/umami/pgdata (owned 70:70)
  • Secrets: /opt/umami/umami.secrets (root, 600) — loaded via env_file; OMV's generated umami.env is not used for secrets because OMV regenerates it and wipes manual edits
  • Backup: not yet in nas16-backup.sh (use pg_dump)
  • Full configuration, lessons learned, and open items: server_umami.md

💳 Debt Eliminator / CutTheCard

NAS16 hosts Debt Eliminator (branded as CutTheCard) as two independent Docker environments.

Domain update — CONFIRMED (2026-09-15): both public domains changed. Production moved from debt.kingdezigns.com to https://www.cutthecard.net; QA moved from debt.qa.kingdezigns.com to https://debt.qa.cutthecard.net. NPM on HAS and Dreamhost DNS have both been updated for both environments — this is a completed rebrand, not just an application-side change. cutthecard.org redirects to cutthecard.net at the Dreamhost DNS level only (not configured in NPM). debt.kingdezigns.com and debt.qa.kingdezigns.com are now deprecated; remaining references to either anywhere in this doc set should be scrubbed and replaced (tracked as a standing reminder in server_debteliminator.md §0a until fully clean). Internal access (192.168.150.40:8002/:8003) is unaffected. Full detail in server_debteliminator.md §2a.

Production

Project:
  /Kingdezignsnas16/debteliminator/

Compose:
  /Kingdezignsnas16/debteliminator/debteliminator.yml

API:
  debteliminator_api

Database:
  debteliminator_db

Host port:
  8002

Internal URL:
  http://192.168.150.40:8002/dashboard/

Public URL:
  https://cutthecard.net/  (www.cutthecard.net also serves the app; cutthecard.org redirects to cutthecard.net at Dreamhost)

QA

Project:
  /Kingdezignsnas16/debteliminator-qa/

Compose:
  /Kingdezignsnas16/debteliminator-qa/debteliminator-qa.yml

API:
  debteliminator_qa_api

Database:
  debteliminator_qa_db

Host port:
  8003

Internal URL:
  http://192.168.150.40:8003/dashboard/

Public URL:
  https://debt.qa.cutthecard.net/

Database storage

Production:
  /opt/debteliminator/pgdata

QA:
  /opt/debteliminator_qa/pgdata

Application stack

  • FastAPI
  • Python 3.12
  • PostgreSQL 16
  • Vanilla HTML/JavaScript/CSS
  • SQLAlchemy
  • AES-256-GCM account-number encryption
  • Charge-level interest rates and promotional APR engine
  • 0% Balance Transfer strategy engine
  • Automated QA → Production deployment engine (deploy_engine.py)
  • Stripe (stripe package, v1.10.0+) — one-time and recurring donations
  • openpyxl / python-docx (v2.3.0+) — Records Archive .xlsx/ .docx year-end export

The app has also grown a small public-facing surface (about/contact/ donate pages, a six-article SEO "Learning Center," robots.txt/ sitemap.xml) alongside the authenticated dashboard. Full detail — including the domain/branding change, self-service account suspend/ delete, and the current known-issues list — is in server_debteliminator.md, which should be treated as authoritative over this summary for anything Debt Eliminator-specific.

Debt Eliminator Database Credentials

Production:

Container: debteliminator_db
Database: debteliminator
User: debteliminator
Password: debteliminator_db_pass

QA:

Container: debteliminator_qa_db
Database: debteliminator
User: debteliminator
Password: debteliminator_qa_db_pass

Debt Eliminator SMTP Credentials

SMTP_HOST=smtppro.zoho.com
SMTP_PORT=465
SMTP_USER=rufus.king@kingdezigns.com
SMTP_PASSWORD=zoho_mail_password
SMTP_FROM=rufus.king@kingdezigns.com
SMTP_TO=rufus.king@kingdezigns.com

These values are intentionally retained in the private NAS16 documentation for operational convenience.

Debt Eliminator deployment commands — standing rule

Every delivery of Debt Eliminator files must open with the exact command block below (real file names; sudo is required because the project directory is root-only). Full template and rules: server_debteliminator.md §3a-0.

scp ~/Downloads/<package>.tar.gz rufusking@192.168.150.40:deploys/   # from KingDezigns001
ssh rufusking@192.168.150.40
cd ~/deploys && rm -rf <name> && mkdir <name> && tar -xzf <package>.tar.gz -C <name>
sudo cp -r ~/deploys/<name>/api/app/. /Kingdezignsnas16/debteliminator-qa/api/app/
sudo docker restart debteliminator_qa_api                            # restart-only change

Rebuild instead of restart when requirements.txt, Dockerfile or compose files change.

Debt Eliminator architecture

KingDezigns001
     ↓
SCP → NAS16 ~/deploys/ (manual path)
     ↓
QA application
     ↓
QA PostgreSQL
     ↓
QA browser testing
     ↓
[Automated] Dev Log → Deploy to Prod (preview → confirm → execute)
  — deploy_engine.py diffs QA vs Production, copies changed files,
    rebuilds if needed, restarts, verifies container status
     ↓
Production application
     ↓
Production PostgreSQL

The QA container requires /var/run/docker.sock and bind mounts of both project directories for the automated pipeline. See server_debteliminator.md §3a for the required compose additions.

2026-09-30 update (host-level summary — server_debteliminator.md §0b/§12f/§12g is authoritative): DevLog is now v2.1.3. Added: a public Blog Engine (/blog, scheduled publishing via an in-app 60-second worker, images stored in PostgreSQL — no new files on disk, no compose changes, no new Python dependencies), a unified revenue ledger (donations.payment_kind), subscription admin tiles, and an Admin → Revenue page. SitePay (real paid subscriptions, Stripe Customer Portal, daily reconciliation) and Email Campaigns are present in the code (see server_debteliminator.md §0b).

2026-10-02 update: Production backup is now v2.1.7 (debteliminator-v2.1.7-backup-2026-10-01_16-35-01.tar.gz; v2.1.4–2.1.7 deployed 2026-09-30/10-01, contents not itemized here). Added a site-wide script loader (static/site-scripts.js) feeding Umami analytics — see server_debteliminator.md §12h and server_umami.md. Static files only plus one edit to routers/blog.py; no new dependencies or compose changes.

2026-10-11 update (host-level summary - server_debteliminator.md §0d/§8b/§12i-12j is authoritative): DevLog is now v2.1.20 (seen in a QA backup, debteliminator-v2_1_20-backup-2026-10-10_23-51-34.tar.gz). New: Admin Roles v2, public Demo Calculator, Milestones, Windfall Allocator, CSV/Statement Import (in memory only, 30-day import history), reminders, Credit Utilization, Budget-to-Payoff, blog auto-archive, Household Sharing, a WCAG 2.2 AA accessibility layer, and a regrouped sidebar. New tables: roles, user_roles, budget_items, budget_settings, import_batches, payment_reminder_log, household_shares, household_activity. No new containers or ports. APP_SECRET_KEY is still unset (also absent from the QA compose file).

Important application behavior

Debt Eliminator uses a transaction-driven ledger:

opening_balance
      +
SUM(transaction signed_amount)
      =
current_balance

The ledger is recomputed on every transaction create/edit/delete.

Future-dated transactions immediately affect displayed balance but are excluded from the interest/payoff balance until their date.

Supported transaction types:

  • Payment
  • Charge (supports per-charge interest rate + promotional APR)
  • Fee
  • Refund
  • Adjustment

Payment Register

Debt Eliminator includes:

/dashboard/register.html

The Payment Register provides a year-at-a-glance view and supports a saved Payments-Only versus All-Transactions preference.

Debt Reduction Plan

/dashboard/payoff-strategy.html

Four-step progressive page: pick a strategy (Avalanche/Snowball), claim 0% balance-transfer savings, adjust payments, follow the rollover timeline. Evaluates balance-transfer opportunities with credit-limit awareness and promo-balance protection warnings.

My Account

All users have:

/dashboard/account.html

Administration

Administrators have:

/dashboard/admin/accounts.html

This manages accounts, security settings, Terms of Use, and audit logging.

Help Center

/dashboard/help.html

Built-in documentation covering all application features. Nav link and page title read Help Center.

Dev Log

Administrators have:

/dashboard/admin/devlog.html

The DevLog records the QA → Production workflow. Includes deployment instructions, attach-to-existing-version for no-version projects, and the automated Deploy to Prod pipeline (preview → confirm → execute via deploy_engine.py).


🔢 Debt Eliminator Version Namespaces

The 2026-09-30 Production backup (v2.1.3) shows these have moved on since the 2026-09-15 backup (v2.0.19), and the frontend cache marker is still not a single value:


Identifier Current value Meaning


DevLog Production v2.1.3 Latest deployed version version stored in project_versions; used by the backup filename

Application source 1.10.1 Version reported by version main.py

Frontend cache marker mixed: 1.8.5 on pages ?v= used for shared touched 2026-09-30, CSS/JS — not yet 1.8.3/1.8.4 on others consistent across pages; see server_debteliminator.md §4.3/§25

When referring to a Debt Eliminator release, documentation should state which namespace is intended.

Recommended wording:

DevLog deployment v2.1.20 (2026-10-10 QA backup; Production latest not re-checked)
Application source v1.10.1 (string not bumped; startup log still says v1.9.2)
Frontend cache marker — app pages ?v=1.9.5; blog.py / public calculator page still ?v=1.9.2, see server_debteliminator.md

💾 Debt Eliminator Backup

Dedicated script:

/usr/scripts/debteliminator/debteliminator-backup.sh

Destination:

/export/kingdezignsnas-16/Public/07 - Projects/NAS16/debteliminator/

The script:

  1. Verifies NAS16 storage
  2. Verifies the Production project directory
  3. Verifies Docker
  4. Verifies the Production PostgreSQL container
  5. Queries the latest deployed DevLog version
  6. Runs pg_dump
  7. Compresses the SQL dump
  8. Copies the Production project files
  9. Creates a manifest
  10. Creates a tar.gz archive
  11. Verifies the archive can be read
  12. Removes temporary files
  13. Retains the 10 newest Debt Eliminator backups

Backup scope

The dedicated backup, most recently reconfirmed on 2026-09-15, is a Production-only backup.

It does not include:

  • QA PostgreSQL data
  • QA project files
  • QA Docker Compose project

Do not describe the dedicated backup as a complete QA/Production backup.

Archive naming

The backup script queries:

SELECT version_number
FROM project_versions
WHERE status = 'deployed'
ORDER BY deployed_at DESC NULLS LAST
LIMIT 1;

The latest Production DevLog version in the 2026-09-30 backup is:

v2.1.3

Therefore the archive is:

debteliminator-v2.1.3-backup-2026-09-30_08-47-16.tar.gz

Security

Debt Eliminator backup archives contain the Production database and application configuration.

Treat them as confidential.

Never place actual passwords, SMTP credentials, database passwords, encryption keys, or session secrets into network documentation.


📅 NAS16 Scheduled Jobs

Existing NAS16 jobs include:


Schedule Script Purpose


Every 3 days /usr/scripts/omv/nas16-backup.sh NAS16 system backup

Every 2 days at /usr/scripts/nas/nas08_to_nas16_sync.sh NAS08 → NAS16 2:30 AM rsync

Daily midnight /usr/scripts/zfs/nas16_zfs_report.sh ZFS status

Sunday 3:00 AM /usr/scripts/zfs/nas16_zfs_scrub.sh ZFS scrub

Every 15 minutes /usr/scripts/ddns/ddns_update.sh DDNS

Wednesday 1:30 AM /usr/scripts/omv/fstrim-report.sh SSD TRIM/SMART report

Every 5 minutes /usr/scripts/crowdsec/cs_notifier.sh CrowdSec notifier

Every 4 hours /usr/scripts/crowdsec/cs_local_digest.sh CrowdSec local digest

Daily midnight /usr/scripts/crowdsec/cs_digest.sh CrowdSec CAPI digest

Debt Eliminator's dedicated backup script is intended to be run through OMV Scheduled Jobs when configured.


🔒 Required Firewall Behavior

Inbound

NAS16 must accept required traffic from:

  • VLAN 1
  • VLAN 20
  • VLAN 50
  • HAS/NPM at 192.168.150.30

Outbound

NAS16 remains subject to VLAN 50's containment rules.

Required local exceptions include:

  • VLAN 50 traffic
  • DNS
  • HAS CrowdSec LAPI at 192.168.150.30:8080
  • Required application/proxy connectivity

Database ports for application databases should not be exposed beyond their required Docker/network scope.


🛡️ Security Notes

  • Fail2Ban active
  • Real IP forwarding configured
  • Webmin access restricted
  • Database services are not publicly exposed directly
  • External application access is through NPM
  • CrowdSec provides perimeter intrusion prevention on HAS
  • VLAN 50 limits lateral movement
  • Debt Eliminator account numbers require stable encryption configuration

Debt Eliminator encryption follow-up — still open, now higher priority

The Production Compose file, re-inspected as of the 2026-09-15 backup, still does not explicitly define APP_SECRET_KEY. This was already flagged as a known issue at the prior reconciliation and remains unresolved.

This is now more urgent: the same Production compose file has since had live Stripe secret/publishable/webhook keys added to it in plaintext (see server_debteliminator.md §5/§26) to support the new donation feature. The compose file is therefore a more sensitive artifact than it was previously, while its most basic secret-hygiene gap is still open. The user has acknowledged this (2026-09-15) and asked to circle back to it later rather than fix it immediately — this is being tracked with a standing reminder in server_debteliminator.md §0a (re-surface every ~5 days until resolved), not silently deferred.

Before relying on stored account-number encryption:

  1. Generate a strong Production secret.
  2. Store it — and the Stripe keys — in the approved secret-management system.
  3. Configure APP_SECRET_KEY in Production.
  4. Configure a separate secret in QA.
  5. Recreate the containers.
  6. Never rotate the Production key after encrypted account numbers have been stored.

The actual secret must not be written into this file.


🧠 Summary for AI Systems

  • NAS16 = OMV + LAMP + database + Forgejo + Fund Tracker + Debt Eliminator (CutTheCard) + CrowdSec notifier.
  • Debt Eliminator is branded CutTheCard. As of 2026-09-15, both public domains changed and are confirmed — production is https://www.cutthecard.net (was debt.kingdezigns.com), QA is https://debt.qa.cutthecard.net (was debt.qa.kingdezigns.com). NPM on HAS and Dreamhost DNS were both updated for both. cutthecard.org redirects to cutthecard.net at Dreamhost only. Both kingdezigns.com domains are deprecated; scrub remaining references (tracked in server_debteliminator.md §0a until clean).
  • Debt Eliminator Production = 192.168.150.40:8002.
  • Debt Eliminator QA = 192.168.150.40:8003.
  • Both environments have independent PostgreSQL containers and storage.
  • NPM on HAS provides external HTTPS.
  • Debt Eliminator deployments are QA-first.
  • The QA Dev Log now drives an automated Deploy to Prod pipeline (preview → confirm → execute via deploy_engine.py), which requires the Docker socket and project bind-mounts in the QA compose config.
  • KingDezigns001 is the deployment workstation for the manual path.
  • Debt Eliminator has a transaction-driven balance ledger.
  • Charge-level interest rates and promotional APR (standard + deferred) are supported per transaction via interest_engine.py.
  • 0% Balance Transfer strategy is in balance_transfer.py; evaluates donor/receiver pairs in Avalanche order; credit_limit field caps recommended amount with a 0.5% safety buffer.
  • The Debt Reduction Plan page (formerly Payoff Strategy) has a four-step progressive layout.
  • Payment Register is a separate dashboard page.
  • My Account and Admin Accounts are current application pages.
  • Help Center page (formerly User Guide) is at /dashboard/help.html.
  • DevLog is QA-driven and carries deployment instructions; it now also tracks assignment/due-date/on-hold per queue item, sends a weekly overdue-item alert email, and keeps a permanent deployment-history table separate from the single-generation file backup.
  • As of the 2026-09-15 backup (DevLog v2.0.19, app source v1.10.1): Debt Eliminator has grown Stripe donations (one-time + recurring), a public Support/Contact form, self-service account suspend/delete, a Privacy Statement + Affiliate Disclosure (affiliate links themselves not yet live), a downloadable Records Archive export, an SEO foundation with a public six-article Learning Center, and a dark/light theme. Full detail is in server_debteliminator.md, which should be treated as authoritative for anything Debt Eliminator-specific — this file only tracks the NAS16-host-level facts.
  • 2026-09-30: DevLog v2.1.3; Blog Engine, revenue ledger/page and subscription admin views added (see the update note above and server_debteliminator.md). The backup archive name is now debteliminator-v2.1.3-backup-2026-09-30_08-47-16.tar.gz.
  • APP_SECRET_KEY is still not configured in Production — now a higher-priority gap since live Stripe keys were added to the same compose file in plaintext. See the encryption follow-up section above.
  • DevLog v2.0.19 is not the same identifier as application source v1.10.1.
  • Frontend cache marker is currently split between 1.8.3 and 1.8.4 depending on the page — no longer a single consistent value; see server_debteliminator.md §4.3/§25.
  • The dedicated Debt Eliminator backup is Production-only.
  • 2026-10-02: Umami analytics runs on NAS16 (umami, umami_db, port 3001, /opt/umami/); CutTheCard pages load it through one loader (/dashboard/site-scripts.js). Latest Debt Eliminator backup seen: v2.1.7. See server_umami.md.
  • 2026-10-11: Home Page Swap — the Debt Eliminator home page ("Start Here") is now served at / and /index.html; / no longer redirects to /dashboard/. See server_debteliminator.md §0e.
  • MANDATORY: every delivery of application files opens with the SCP → sudo cp → sudo docker restart debteliminator_qa_api command block (restart-vs-rebuild stated). See the standing rule above and server_debteliminator.md §3a-0.
  • Never document actual credentials or encryption keys.
  • APP_SECRET_KEY should be explicitly configured before relying on account-number encryption.

✔️ End of File