diff --git a/README.md b/README.md index 6032c9c..3fb4eb6 100644 --- a/README.md +++ b/README.md @@ -69,18 +69,22 @@ nötig. HTTP bleibt der Standard für bestehende Installationen. Im Abschnitt **HTTPS / TLS** der WebGUI werden Zertifikat-/Keypfade geprüft und gespeichert; ein ausdrücklicher Neustart aktiviert HTTPS auf demselben Port. Bearer-Key und Toolfreigaben bleiben unverändert. Fehlende/ungültige TLS-Dateien verhindern den -Start ohne HTTP-Fallback. Das bestehende Unraid-WebGUI-PEM-Bundle kann nach -expliziter Auswahl für beide Pfadfelder verwendet werden, ohne Schlüsselkopie; -Clients erhalten nur den öffentlichen Zertifikatsteil und gezielten Trust +Start ohne HTTP-Fallback. Das bestehende Unraid-WebGUI-PEM-Bundle wird im +Unraid-Modus ohne Pfadeingabe verwendet, im Expertenmodus für beide Pfadfelder; +keine Schlüsselkopie. Clients erhalten nur den öffentlichen Zertifikatsteil und gezielten Trust (Hermes: `ssl_verify` je MCP-Server). Details zu `tls.conf`, Zertifikaten, Erneuerung, Client-Trust und synthetischen Tests: **[docs/HTTPS.md](docs/HTTPS.md)**. -Im regulären **r034-Paket** enthalten; das alte r033-Archiv bleibt unverändert. -**Ein Update aktiviert HTTPS nicht automatisch.** Erst das bestätigte vorhandene -Bundle wählen, Client-Trust/SAN vorbereiten, TLS speichern und MUA bewusst neu -starten. Installation und Umstellung führt der Betreiber durch; kein automatischer -Zertifikats-/DNS-Austausch und keine API-Key-Rotation sind nötig. -Release-/Prüfhinweise: [docs/RELEASE-r034.md](docs/RELEASE-r034.md). +Natives HTTPS ist seit r034 enthalten. Ab **2026.11.05.r035** genügt in der WebGUI +**„Unraid-WebGUI-Zertifikat verwenden“**: keine manuellen Server-Dateipfade nötig. +Bei mehreren aktiven SNI-Zertifikaten den gewünschten WebGUI-Zugriffsnamen wählen; +ungenutzte PEM-Dateien werden nie automatisch ausgewählt. Eigene absolute Pfade +bleiben als **Expertenoption** erhalten, bestehende r034-Pfadkonfigurationen +bleiben unverändert. **Ein Update aktiviert HTTPS nicht automatisch.** Client- +Trust/SAN vorbereiten, TLS prüfen/speichern und MUA bewusst neu starten. +Keine automatische Zertifikats-/DNS-Änderung oder API-Key-Rotation. +Auswahl, Versionen und Grenzen: [docs/UNRAID-CERTIFICATES.md](docs/UNRAID-CERTIFICATES.md). +Die veröffentlichten r033-/r034-Archive werden nicht überschrieben. ## Sicherheitsmodell @@ -128,10 +132,10 @@ Oder manuell: ```bash # .txz von Gitea laden -curl -fLO https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-2026.11.05.r034-x86_64-1.txz +curl -fLO https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-2026.11.05.r035-x86_64-1.txz # Installieren -upgradepkg --install-new mua-2026.11.05.r034-x86_64-1.txz +upgradepkg --install-new mua-2026.11.05.r035-x86_64-1.txz ``` ### 2. Service starten @@ -146,7 +150,7 @@ Der Service startet automatisch bei jedem Boot (SysVinit). ```bash curl http://UNRAID-IP:3002/health -# → {"status":"ok","version":"2026.11.05.r034","auth":"required"} +# → {"status":"ok","version":"2026.11.05.r035","auth":"required"} ``` Bei aktiviertem TLS den zertifizierten Namen mit `https://` und passendem diff --git a/docs/HERMES.md b/docs/HERMES.md index d59f6f8..4077559 100644 --- a/docs/HERMES.md +++ b/docs/HERMES.md @@ -98,8 +98,11 @@ HTTP-Server angelegt werden: ## Gezielt einem selbstsignierten MUA-Zertifikat vertrauen -Das vorhandene Unraid-WebGUI-Bundle kann auf dem **Server** für beide MUA- -TLS-Pfade verwendet werden. Auswahl, Export und Erneuerung stehen in +Ab r035 in der MUA-WebGUI **„Unraid-WebGUI-Zertifikat verwenden“** wählen, +bei mehreren Identitäten den gewünschten Zugriffsnamen. Keine manuellen Server- +Zertifikatspfade nötig; Expertenpfade bleiben möglich. Sichere Ableitung und +Versionsgrenzen: [UNRAID-CERTIFICATES.md](UNRAID-CERTIFICATES.md). +Auswahl, öffentlicher Export und Erneuerung stehen in [HTTPS.md](HTTPS.md#vorhandenes-selbstsigniertes-unraid-webgui-bundle-wiederverwenden). Auf den **Client** gehört ausschließlich das separat exportierte öffentliche Zertifikat, niemals das Bundle mit privatem Schlüssel. diff --git a/docs/HTTPS.md b/docs/HTTPS.md index 1c41b7f..2aa2a27 100644 --- a/docs/HTTPS.md +++ b/docs/HTTPS.md @@ -11,6 +11,11 @@ nicht automatisch** und ändert weder bestehenden API-Key noch Toolfreigaben. Manifest und Paket-Hook prüfen die lokale Bereitschaft mit `/etc/rc.d/rc.mua health`, nicht über einen fest kodierten HTTP-MCP-Endpunkt. +Ab **r035** bietet die WebGUI **„Unraid-WebGUI-Zertifikat verwenden“**, ohne +manuelle Server-Dateipfade. Auswahlregeln, geprüfte Unraid-Versionen und Grenzen: +[UNRAID-CERTIFICATES.md](UNRAID-CERTIFICATES.md). r034 bleibt unverändert abrufbar; +vorhandene manuelle TLS-Einstellungen werden beim Update nicht still umgestellt. + - Ohne `tls.conf` bzw. mit `MUA_TLS_ENABLED=false`: bestehendes HTTP auf Port 3002. - Mit `MUA_TLS_ENABLED=true`: **ausschließlich HTTPS auf demselben Port**, einschließlich `/health`. Kein zusätzlicher HTTP-Port, kein Redirect und @@ -68,7 +73,18 @@ Es liest bei identischen Pfaden einen gemeinsamen Snapshot; es trennt den Key nicht auf Platte ab, kopiert oder ändert die Quelldatei nicht und sucht keine Zertifikatskandidaten automatisch. -### Zuerst das tatsächlich aktive Zertifikat bestimmen +### Ohne Pfadeingabe: Unraid-WebGUI-Zertifikat verwenden + +In MUA **HTTPS aktivieren → Unraid-WebGUI-Zertifikat verwenden** wählen. Der +Dienst liest Management-Laufzeitdaten und die erzeugte nginx-Konfiguration als +Daten, ohne Configs auszuführen. Bei genau einer aktiv konfigurierten HTTPS- +WebGUI-Identität ist keine Pfadeingabe nötig. Bei mehreren SNI-Identitäten den +gewünschten WebGUI-Zugriffsnamen ausdrücklich auswählen. Reine 404-/Redirect- +Server, ungenutzte Bundles und unbekannte Konfigurationen werden nicht geraten. +Danach prüfen/speichern und bewusst MUA neu starten; Client-Trust/SAN separat +vorbereiten. Dieser Modus ändert oder erzeugt kein WebGUI-Zertifikat. + +### Expertenoption: tatsächlich aktiven Pfad ausdrücklich vorgeben Ein berechtigter Betreiber muss den **exakten aktiven Bundle-Pfad für den gewünschten WebGUI-Endpunkt** aus der vorhandenen Management-Access-/effektiven @@ -85,11 +101,12 @@ Beispielpfade für Custom-Zertifikate sind **keine automatische Auswahlregel** für das vorhandene selbstsignierte Zertifikat. Dieser Entwicklungsauftrag hat auf keinem realen Unraid einen Pfad oder SAN festgestellt. -Nach expliziter Auswahl in der MUA-WebGUI beide Pfadfelder gleich setzen oder +Nur bei **Expertenoption: eigene Zertifikatspfade** beide Pfadfelder gleich setzen oder `tls.conf` verwenden (unten steht bewusst **kein geratener Server-Dateiname**): ```ini MUA_TLS_ENABLED=true +MUA_TLS_SOURCE=manual MUA_TLS_CERT_FILE=/exakt/bestaetigter/aktiver-webgui-bundle.pem MUA_TLS_KEY_FILE=/exakt/bestaetigter/aktiver-webgui-bundle.pem ``` @@ -136,8 +153,9 @@ Ein Austausch des WebGUI-Bundles aktualisiert einen laufenden MUA **nicht** automatisch. Der alte Listener behält seinen beim Start gelesenen Snapshot. Nach autorisiertem Austausch `mua --check-config` und einen gezielten `rc.mua restart` ausführen. Ein defektes Bundle wird vor dem Stop erkannt; der -alte Listener bleibt bestehen, ohne HTTP-Fallback. Wechselt der aktive Pfad, -müssen beide MUA-Pfade ausdrücklich angepasst werden. +alte Listener bleibt bestehen, ohne HTTP-Fallback. Verschwindet die bisher +gewählte WebGUI-Identität, im Unraid-Modus erneut den gewünschten Namen wählen; +im Expertenmodus beide Pfade ausdrücklich anpassen. Beim neuen selbstsignierten Zertifikat den öffentlichen Export und Fingerprint neu bestätigen und den **gezielten Client-Trust** aktualisieren. Ein alter @@ -152,7 +170,8 @@ WebGUI-/Gateway-Neustart und keine pauschale Key-Rotation sind Teil dieses Wegs. Unter **Settings → User Utilities → MUA → HTTPS / TLS**: -1. Absoluten Pfad zur Fullchain und zum privaten Schlüssel eintragen. +1. **Unraid-WebGUI-Zertifikat verwenden** wählen, gegebenenfalls SNI-Namen + auswählen; keine Serverpfade eingeben. Eigene Pfade nur in der Expertenoption. 2. **HTTPS aktivieren** wählen, dann **TLS prüfen und speichern**. 3. MUA prüft Lesbarkeit, PEM, Key-Zuordnung und Zertifikatsgültigkeit **vor** dem Speichern. Ungültige Angaben ändern weder die Datei noch den laufenden Listener. @@ -163,7 +182,7 @@ Unter **Settings → User Utilities → MUA → HTTPS / TLS**: Die angezeigte Server-IP gegebenenfalls durch den zertifizierten DNS-Namen ersetzen. Die WebGUI zeigt aktive und gespeicherte Einstellungen getrennt und -übermittelt ausschließlich Dateipfade, niemals PEM-Inhalte oder Passphrasen. +übermittelt Modus/Auswahl-IDs bzw. Experten-Dateipfade, niemals PEM-Inhalte oder Passphrasen. ### Datei / Umgebung @@ -171,10 +190,16 @@ ersetzen. Die WebGUI zeigt aktive und gespeicherte Einstellungen getrennt und ```ini MUA_TLS_ENABLED=true +MUA_TLS_SOURCE=manual MUA_TLS_CERT_FILE=/geschuetzter/persistenter/pfad/fullchain.pem MUA_TLS_KEY_FILE=/geschuetzter/persistenter/pfad/privkey.pem ``` +Ohne `MUA_TLS_SOURCE` bleiben bestehende nichtleere r034-Pfade im manuellen +Modus. `MUA_TLS_SOURCE=unraid` leitet den Pfad erneut aus Unraids Laufzeitstand +ab; die GUI speichert `MUA_TLS_UNRAID_CERT` als opaque Auswahl-ID. Fehlt eine ID, +ist nur genau eine aktive Identität zulässig. Nie eine ID oder einen Pfad raten. + Die Datei ist einfaches `NAME=WERT`, ohne Shell-Quoting, Expansion oder `export`. Kommentare beginnen mit `#`; doppelte/unbekannte Einträge und ungültige Flags werden abgelehnt. `MUA_TLS_ENABLED` akzeptiert genau `true` oder `false`. diff --git a/docs/RELEASE-r035.md b/docs/RELEASE-r035.md new file mode 100644 index 0000000..9437b8f --- /dev/null +++ b/docs/RELEASE-r035.md @@ -0,0 +1,97 @@ +# Release 2026.11.05.r035 — Unraid-Zertifikat ohne Pfadeingabe + +r034 war bei Eingang der UX-Korrektur bereits veröffentlicht. Dieses neue Release +ersetzt **kein** veröffentlichtes Archiv: r033 und r034 bleiben bytegleich. + +## Für den Betreiber + +In Unraid **Plugins → Install Plugin**: + +```text +https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg +``` + +Bei vorhandenem MUA normal **Plugins → MUA → Update** verwenden. Das Update +startet MUA neu, verändert aber weder API-Key/Toolfreigaben noch die aktivierte +Transportart. Bestehende r034-Pfadkonfigurationen bleiben im Expertenmodus. + +Danach **Settings → User Utilities → MUA → HTTPS / TLS**: + +1. **HTTPS aktivieren → Unraid-WebGUI-Zertifikat verwenden**. +2. Bei einer erkannten HTTPS-WebGUI keine Pfade eingeben; bei mehreren aktiven + SNI-Identitäten den gewünschten WebGUI-Namen ausdrücklich auswählen. +3. **TLS prüfen und speichern**, anschließend **bewusst neu starten**. +4. Client-Trust ausschließlich mit öffentlichem Zertifikat herstellen, passenden + SAN-Namen verwenden und HTTPS plus authentifiziertes MCP prüfen. Vorhandenen + Bearer-Key sicher beibehalten; keine beiläufige Rotation. + +Ohne explizites `MUA_TLS_SOURCE=unraid` findet keine Wiederverwendung durch den +Dienst statt. Die frische GUI empfiehlt den Modus, aktiviert ihn aber nicht +selbst. Keine Suche nach beliebigen PEM-Dateien und keine WebGUI-Zertifikatserzeugung. +Vollständige Ableitungsregeln, öffentliche Quellen und Versionsgrenzen: +[UNRAID-CERTIFICATES.md](UNRAID-CERTIFICATES.md). + +## Paket und Installationspfad + +- Version: `2026.11.05.r035` +- Dateiname: `mua-2026.11.05.r035-x86_64-1.txz` +- Bytes: `24831000` +- SHA256: `7a861d2a0b917b3d09e96f9ec97fd72fb070ba2fdcbbf4456ee9832d972d23b1` +- TXZ: `https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-2026.11.05.r035-x86_64-1.txz` +- Mindestplattform: Unraid `7.0.0`, x86_64 +- Plugin-Downloadziel: `/boot/config/plugins/mua/mua-2026.11.05.r035-x86_64-1.txz`, + `upgradepkg --install-new`; Paket-Hook und Manifest verwenden `rc.mua health`. +- Vorheriger veröffentlichter Quellstand: `7e2fac5c1961456d85a79444168e227fc5a783ca`. + +## Tatsächliche Entwicklungsabnahme + +Linux x86_64; ausschließlich synthetische Zertifikate, Daten, Dateisystempräfixe +und Loopback-Prozesse. Bun **1.3.14**, TypeScript **5.9.3**, OpenSSL **3.5.7**, +curl **8.14.1**, PHP **8.4.27**, Python **3.12.15**. + +| Prüfung | Ergebnis | +|---|---| +| Quellsuite | **109/109**, 6 Dateien | +| Gesamte Transport-/Service-/PHP-WebGUI-Suite gegen aus r035 entpacktes Binary | **35/35** | +| PHP Notifications / Docker-Update / Storage / Admin | **9 / 10 / 10 / 23** Prüfungen | +| Release-/Manifest-/Archiv-/isolierte Hooktests | **8/8**, nichts übersprungen | +| Frozen dependencies, TypeScript, PHP-/Bash-Syntax, Plugin-XML, Diff | erfolgreich | +| Archiv | **22 Einträge**, root:root, korrekte Modi, keine PEM-/Key-/Configdateien | +| Synthetischer 64-MiB-Ausgabetest | Exit 0, Ausgabe begrenzt | + +Die Quellsuite enthält **37** Resolver-/Parserprüfungen mit **25** aus offiziellen +rc.nginx-Templates erzeugten Fixtures für 7.0.0, 7.1.0, 7.2.0, 7.3.4 und +7.4.0-rc.2.5. Herkunft/Quellhashes stehen unter `test/fixtures/unraid-webgui/`. +Zusätzlich real ausgeführt: pfadfreier Speichervorgang und expliziter Wechsel von +HTTP zu verifiziertem HTTPS, MCP initialize/tools/list/Read-only-Aufruf, 401 ohne +Bearer und Ablehnung falschen Trusts, PHP-WebGUI mit Auswahl mehrerer SNI-Bundles, +CSRF und Experten-Rückwärtskompatibilität. Fehlender Laufzeitstand, verschwundene +Auswahl, nicht explizit gewählter Modus sowie null/ungültige Eingaben werden +abgelehnt, ohne Experten-/HTTP-Fallback oder Konfigurationsausführung. + +Die neuen Verhaltensfälle wurden vor ihrer jeweiligen Implementierung rot und +anschließend grün ausgeführt. Der unabhängige Code-Review-Befund und der exakte +veröffentlichte Release-Commit werden im Entwickler-Handoff separat ausgewiesen; +diese Entwicklungsprüfungen sind keine unabhängige Testwiederholung. + +Review-Nachbesserungen sind ebenfalls regressionsgeprüft: manuelle GUI-Saves +bleiben im r034-lesbaren Format, Unraid-Erkennung läuft nur bei der GUI-Konfig- +Abfrage (nicht im Bereitschaftscheck oder jedem Save), und eigene serverweite +nginx-Steuerung führt zu einem klaren Fehler statt zum stillen anderen SNI- +Bundle. Vor einem bewussten Rollback aus dem Unraid-Modus muss dessen neue +Konfiguration kontrolliert in ein altes Experten-Setup migriert werden; r034 +versteht die neuen Unraid-Modus-Schlüssel nicht. + +## Grenzen + +Keine native Installation oder Boot-Abnahme auf echtem Unraid/emhttp und keine +reale Hermes-MCP-Verbindung zum NAS. Automatische Ableitung benötigt die bereits +erzeugten WebGUI-Laufzeitdateien beim Start; fehlen sie, bleibt MUA geschlossen +und muss nach verfügbarem WebGUI-Stand gezielt gestartet werden. Es wird kein +Boot-Reihenfolge-Erfolg behauptet. Die erzeugte nginx-Konfiguration beweist nicht +kryptographisch den im nginx-Speicher geladenen Zustand nach einem fehlgeschlagenen +Reload; Betreiber müssen diesen Sonderfall klären und TLS separat verifizieren. + +Keine Serverinstallation, Service-Neustarts, Zertifikats-/DNS-/Client-Trust- +Änderungen oder API-Key-Rotation wurden durch die Entwicklung/Veröffentlichung +vorgenommen. Installation und HTTPS-Umschaltung bleiben beim Betreiber. diff --git a/docs/UNRAID-CERTIFICATES.md b/docs/UNRAID-CERTIFICATES.md new file mode 100644 index 0000000..f85dc1f --- /dev/null +++ b/docs/UNRAID-CERTIFICATES.md @@ -0,0 +1,121 @@ +# Unraid-WebGUI-Zertifikat ohne manuelle Serverpfade + +Ab **2026.11.05.r035** unter **Settings → User Utilities → MUA → HTTPS / TLS**: + +1. **HTTPS aktivieren** und **Unraid-WebGUI-Zertifikat verwenden** wählen. +2. Gibt es genau eine aktiv konfigurierte HTTPS-WebGUI-Identität, muss kein Pfad + eingegeben werden. Bei mehreren Identitäten den gewünschten WebGUI-/SNI- + Zugriffsnamen ausdrücklich auswählen; die erste Listeintragung ist kein Default. +3. **TLS prüfen und speichern**. Anschließend MUA **bewusst neu starten**. +4. Client-URL mit passendem Zertifikat-SAN und öffentlichem Trust verwenden, + vorhandenen Bearer-Key beibehalten und TLS/MCP prüfen. Lokale Bereitschaft + allein ersetzt weder Trust-/Hostnamenprüfung noch authentifizierte MCP-Aufrufe. + +Keine neue CA, kein neues WebGUI-Zertifikat und keine Schlüsselkopie nötig. +Die bisherige manuelle Pfadkonfiguration bleibt als **Expertenoption** erhalten; +vorhandene r034-Einstellungen werden nicht still auf den neuen Modus umgestellt. +Installation/Update allein aktiviert HTTPS nicht. + +GUI-Speichervorgänge im Expertenmodus behalten das dreischlüsselige r034-Dateiformat +bei. Der neue Unraid-Modus benötigt dagegen `MUA_TLS_SOURCE`/`MUA_TLS_UNRAID_CERT`, +die r034 nicht kennt. Vor einem bewusst geplanten Rückwechsel muss diese neue +Konfiguration kontrolliert in ein r034-kompatibles Experten-Setup migriert werden; +nicht blind TLS-Einträge löschen oder HTTP als Fehlerumgehung aktivieren. + +## Was als aktiv konfiguriert gilt + +MUA liest ausschließlich Daten, niemals Shell-Code: + +- `/etc/unraid-version`: geprüftes Unraid-Konfigurationsformat; +- `/var/local/emhttp/nginx.ini`: von rc.nginx erzeugter Management-Laufzeitstand + (`NGINX_USESSL`, `NGINX_PORTSSL`, `NGINX_LANMDNS`); +- `/etc/nginx/nginx.conf` und eingeschlossene Dateien **innerhalb `/etc/nginx/`**: + HTTPS-`server`-Blöcke am Management-Port, die Unraids WebGUI-`locations.conf` + verwenden. Kommentare, Strings und Blockgrenzen werden als nginx-Daten geparst. + +Nur deren tatsächliche `ssl_certificate`-/`ssl_certificate_key`-Direktiven zählen. +Beide müssen dasselbe vorhandene PEM-Bundle unter `/boot/config/ssl/certs/` +bezeichnen. MUA durchsucht dieses Zertifikatsverzeichnis **nicht** nach Kandidaten. +Ein unbenutztes oder neueres Bundle wird nicht gewählt. Reine Redirect-/404- +Server werden ausgeschlossen, auch wenn sie ein SSL-Standardzertifikat tragen. + +Der konfigurierte Zertifikatspfad kann etwa `[servername]_unraid_bundle.pem` +oder `certificate_bundle.pem` sein. Welcher tatsächlich gilt, folgt aus dem +WebGUI-Serverblock, **nicht** aus diesem Dateinamenbeispiel. Mehrere unterschiedliche +aktive Bundles werden als benannte Auswahl angezeigt. Die gespeicherte Auswahl +ist eine stabile opaque ID; man muss weder Dateinamen noch absolute Pfade kennen. +Verschwindet diese Identität später, wird nicht still ein anderes Bundle gewählt. + +Die Ableitung liest keine PEM-Inhalte. Erst die TLS-Prüfung lädt das gewählte +Bundle **einmal** für Zertifikat und Key aus demselben Buffer. Zertifikats-/Key- +Zuordnung, Gültigkeit und Fehlerbehandlung bleiben dieselben wie im Expertenmodus. +UI und Logs erhalten keine privaten Schlüsselinhalte. + +Es werden weder `eval`, `source`, `nginx -T` noch `rc.nginx` ausgeführt. MUA +ändert keine Management-Einstellungen und erzeugt, ersetzt oder erneuert keine +Unraid-Zertifikate. Generierte Konfigurationsdateien sind kein kryptographischer +Beweis des derzeit im nginx-Speicher geladenen Zertifikats: nach fehlgeschlagenen +WebGUI-Reloads muss der Betreiber Unraids Zustand zuerst klären. Entfernte TLS- +Verifikation bleibt immer separat erforderlich. + +## Versionen und echte Quellfixtures + +Quellprüfung und reproduzierbare synthetische Konfigurationsfixtures stammen aus +Unraids **offiziellem WebGUI-Repository**, nicht aus einem geratenen Serverpfad: + +| WebGUI-Tag | rc.nginx-Quellstand | +|---|---| +| 7.0.0 | [71a85f0](https://github.com/unraid/webgui/blob/71a85f020b9b1bce48b5bec75d69d78a57d8df3d/etc/rc.d/rc.nginx) | +| 7.1.0 | [93e1ce1](https://github.com/unraid/webgui/blob/93e1ce11c59494b408dc8b0be250f8d4bdab5290/etc/rc.d/rc.nginx) | +| 7.2.0 | [1018244](https://github.com/unraid/webgui/blob/1018244c1f0d525b3a9229b7ea597d315cc77120/etc/rc.d/rc.nginx) | +| 7.3.4 | [31c22f8](https://github.com/unraid/webgui/blob/31c22f8327cca774dcbddd573dc76f70e87b2f10/etc/rc.d/rc.nginx) | +| 7.4.0-rc.2.5 | [b135287](https://github.com/unraid/webgui/blob/b135287c706a30da44f71cc7820615209e83e9a0/etc/rc.d/rc.nginx) | + +Die [aktuelle ManagementAccess.page](https://github.com/unraid/webgui/blob/b135287c706a30da44f71cc7820615209e83e9a0/emhttp/plugins/dynamix/ManagementAccess.page) +liest ebenfalls `nginx.ini` und behandelt lokale/Custom- und Myunraid-Bundles +getrennt. Die [offizielle Verbindungsdokumentation](https://docs.unraid.net/unraid-os/system-administration/secure-your-server/securing-your-connection/) +beschreibt SSL-Modi, Custom-Bundle-Pfad, SAN und verschiedene Zugriffswege. + +Unter `test/fixtures/unraid-webgui/` liegen **25** Fixtures: je Version lokale +HTTPS-WebGUI, HTTPS mit zusätzlichen SNI-Namen, Strict/Auto mit 404-Fallback, +HTTP-only sowie HTTP mit zusätzlichem TLS-SNI-Endpunkt. Sie wurden aus der +originalen `build_servers()`-Templatefunktion mit synthetischen Variablen und +isolierten listen/redirect-Stubs erzeugt; **keine Live-Host-Captures**. Vollständige +Quell-URLs und SHA256 stehen in `provenance.json`. Weder das komplette rc.nginx +noch dessen Zertifikats-/Netzwerk-/Servicefunktionen wurden ausgeführt. + +Das sind geprüfte **Konfigurationsformate**, keine native Installation auf jeder +Unraid-Version. Automatische Ableitung akzeptiert die geprüfte 7.0–7.4-Familie; +unbekannte Versionen/Strukturen werden abgelehnt. Das Plugin selbst behält +Unraid 7.0.0 als Mindestversion. Für eigene/ältere/zukünftige Konfigurationen +steht der bewusste Expertenmodus bereit, ohne automatische Rückstufung. + +## Fehler, Start und Erneuerung + +- Laufzeitdateien und Bundle müssen bei **jedem** Start/Preflight verfügbar sein. + Fehlen sie etwa beim frühen Boot, bleibt der Start geschlossen. Nach verfügbarem + WebGUI-Stand über einen autorisierten lokalen Administrationsweg gezielt starten; + MUA wartet nicht unbegrenzt, baut nichts nach und nimmt kein geratenes Bundle. +- Unbekannter Modus, mehrdeutige Auswahl, unlesbare Dateien, zyklische/unsichere + Includes, dynamische Zertifikatspfade, getrennte nginx-Cert-/Keydateien oder + mehrere Zertifikatspaare in einem WebGUI-Block führen zu einer verständlichen + Fehlermeldung. Keine stillschweigende Wahl des Standard-/neuesten Zertifikats. +- Eigene serverweite `return`-/`if`-/`rewrite`-/`break`-Steuerung in einem + HTTPS-WebGUI-Block ist nicht automatisch interpretierbar und wird abgelehnt, + statt den Block zu überspringen und irrtümlich das andere SNI-Bundle zu wählen. + Die unveränderten reinen 404-/Redirect-Blöcke der geprüften rc.nginx-Templates + werden strukturell ohne WebGUI-Locations erkannt und ausgeschlossen. +- Keine WebGUI-HTTPS-Identität: nicht irgendein vorhandenes Self-signed-Bundle + verwenden. Management Access bewusst prüfen; MUA schaltet die WebGUI nicht um. +- Austausch unter demselben Bundle-Pfad benötigt weiterhin **expliziten Neustart**. + Neue Pfade/Identitäten müssen bei verschwundener alter Auswahl neu bestätigt + werden. Ungültiger Restart-Preflight lässt den laufenden MUA unverändert. +- Bei Selbstsignatur nur das **öffentliche** Zertifikat gezielt dem Client + bereitstellen und Fingerprint bestätigen; niemals Bundle oder Key übertragen. + Trust-/SAN-Anleitung und Expertenexport: [HTTPS.md](HTTPS.md). + +Entwicklungstests verwenden `MUA_UNRAID_ROOT` als synthetischen Dateisystempräfix. +Dieser Test-Override bleibt im normalen Betrieb **ungesetzt** und wird weder in +der WebGUI angeboten noch in `tls.conf` gespeichert. Er ist keine Container-/ +Remote-Host-Erkennung. Produktivserver, DNS, Client-Trust und API-Keys wurden bei +Entwicklung/Veröffentlichung nicht geändert. diff --git a/mcp/helpers.php b/mcp/helpers.php index fdbc961..97c04ed 100644 --- a/mcp/helpers.php +++ b/mcp/helpers.php @@ -10,7 +10,7 @@ error_reporting(E_ALL); ini_set('display_errors', 0); // Fehler werden als JSON-RPC-Error zurückgegeben, nicht als HTML -const MUA_VERSION = '2026.11.05.r034'; +const MUA_VERSION = '2026.11.05.r035'; const MUA_SERVER_NAME = 'mua'; /** diff --git a/mcp/server.php b/mcp/server.php index f336334..436d192 100644 --- a/mcp/server.php +++ b/mcp/server.php @@ -21,7 +21,7 @@ const MUA_PORT = 3002; const MUA_BIND = '0.0.0.0'; const MUA_SESSION_TTL = 3600; // Sekunden const MUA_SERVER_NAME = 'mua'; -const MUA_VERSION = '2026.11.05.r034'; +const MUA_VERSION = '2026.11.05.r035'; // ── Session-Management (in-memory) ─────────────────────────────────────── $sessions = []; // session_id => ['created' => time, 'initialized' => bool] diff --git a/package.json b/package.json index 9e0c041..78d39ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mua", - "version": "2026.11.05.r034", + "version": "2026.11.05.r035", "description": "Mikes Unraid Agent - MCP over HTTP(S) (Streamable HTTP) for Unraid", "type": "module", "main": "src/index.ts", diff --git a/plugin/mua.plg b/plugin/mua.plg index 67ef54c..2bbcd5d 100644 --- a/plugin/mua.plg +++ b/plugin/mua.plg @@ -2,13 +2,13 @@ - + - - + + ]> +### 2026.11.05.r035 +- Neuer expliziter Modus „Unraid-WebGUI-Zertifikat verwenden“: keine manuellen Zertifikatspfade nötig; bisherige Pfade bleiben als Expertenoption erhalten. +- Leitet verwendete Bundles aus der erzeugten nginx-Konfiguration und Management-Laufzeitdaten ab, nicht aus beliebigen PEM-Dateien oder Änderungszeiten. +- Mehrere aktive WebGUI-/SNI-Zertifikate benötigen eine verständliche Namensauswahl; reine 404-/Redirect-Blöcke und ungenutzte Bundles werden nicht gewählt. +- Unbekannte/fehlende Konfigurationen und verschwundene Auswahlen werden abgelehnt, ohne Configs auszuführen oder Unraid-Zertifikate zu ändern. +- Gemeinsamer PEM-Snapshot, Client-SAN-/Trust-Prüfung, bestehende Auth-/Toolfreigaben und ausdrücklicher Neustart bleiben erhalten; versionierte Unraid-Quellfixtures und Regressionstests ergänzt. + ### 2026.11.05.r034 - Optionales natives HTTPS auf dem bisherigen MCP-Port; bestehende HTTP-Installationen, API-Keys und Toolfreigaben bleiben erhalten. - Prüft PEM-Dateien, passenden unverschlüsselten Key und Gültigkeit vor Start/Neustart; kein stiller HTTP-Fallback bei TLS-Fehlern. @@ -205,7 +212,7 @@ Das .txz enthält: install/doinst.sh (läuft nach Installation) =========================================== --> - + &txzURL; &txzSHA256; diff --git a/plugin/plugin.json b/plugin/plugin.json index 45b6a85..71e22a9 100644 --- a/plugin/plugin.json +++ b/plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "mua", "author": "Michael", - "version": "2026.11.05.r034", + "version": "2026.11.05.r035", "minver": "7.0.0", "pluginDirectory": "/usr/local/emhttp/plugins/mua", "configDirectory": "/boot/config/plugins/mua", diff --git a/scripts/mua.page b/scripts/mua.page index 0806244..8d61250 100644 --- a/scripts/mua.page +++ b/scripts/mua.page @@ -98,6 +98,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($action === 'save_toolbox') $payload = ['toolboxEnabled' => isset($_POST['toolbox_enabled'])]; if ($action === 'save_tls') $payload = ['tls' => [ 'enabled' => isset($_POST['tls_enabled']), + 'source' => $_POST['tls_source'] ?? 'manual', + 'unraidChoice' => $_POST['tls_unraid_choice'] ?? '', 'certFile' => $_POST['tls_cert_file'] ?? '', 'keyFile' => $_POST['tls_key_file'] ?? '', ]]; @@ -132,6 +134,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $transport = is_array($config['transport'] ?? null) ? $config['transport'] : []; $tls = is_array($transport['tls'] ?? null) ? $transport['tls'] : []; +$tls_source = ($tls['source'] ?? 'unraid') === 'manual' ? 'manual' : 'unraid'; +$unraid_tls = is_array($transport['unraid'] ?? null) ? $transport['unraid'] : []; +$unraid_choices = is_array($unraid_tls['choices'] ?? null) ? $unraid_tls['choices'] : []; $tls_locked = !$config_ok || !empty($transport['envOverride']); $enabled_tools = $config['enabledTools'] ?? []; $all_tools_enabled = (bool)($config['allToolsEnabled'] ?? false); @@ -181,10 +186,23 @@ $active_count = $all_tools_enabled ? count($all_tools) : count($enabled_tools);
>TLS-Konfiguration +

+

Im Unraid-Modus werden die wirksamen WebGUI-Zertifikate aus der erzeugten nginx-Konfiguration und Management-Laufzeitdaten erkannt. Du musst keinen Dateipfad kennen. Es wird kein Zertifikat erzeugt oder verändert.

+
+

+
>Expertenoption: absolute PEM-Pfade (nur bei manueller Quelle)

+
-

Nur Pfade, keine Schlüssel hochladen/einfügen. Bei einem bestehenden Unraid-WebGUI-Bundle dürfen beide Pfade auf dieselbe ausdrücklich ausgewählte Datei zeigen; keine automatische Kandidatensuche. Nur den öffentlichen Zertifikatsteil zum Client übertragen, niemals das Bundle. Dateien müssen beim Boot bereits lesbar sein. Clients benötigen die passende CA und einen Hostnamen/IP im Zertifikat-SAN; die angezeigte Server-IP gegebenenfalls durch den Zertifikat-DNS-Namen ersetzen. Zertifikatserneuerung erfordert Prüfung und Neustart. Verwaltung bleibt HTTP auf 127.0.0.1:. Lokale Bereitschaft ist kein Client-Trust-Test.

+

Keine Schlüssel hochladen/einfügen. Unraid-Modus: nur aktiv konfigurierte HTTPS-WebGUI-Zertifikate, keine Suche nach der neuesten PEM-Datei. Mehrere SNI-Identitäten brauchen eine ausdrückliche Auswahl; unbekannte Konfigurationen werden abgelehnt. Expertenmodus: beide Pfade dürfen dasselbe Bundle bezeichnen. Nur den öffentlichen Zertifikatsteil zum Client übertragen, niemals das Bundle. Zertifikat und WebGUI-Laufzeitkonfiguration müssen beim Start lesbar sein. Clients benötigen gezielten Trust und einen Hostnamen/IP im Zertifikat-SAN; die angezeigte Server-IP gegebenenfalls ersetzen. Speichern ändert den laufenden Listener nicht; Erneuerung und Aktivierung erfordern ausdrücklich Neustart. Verwaltung bleibt HTTP auf 127.0.0.1:. Lokale Bereitschaft ist kein Client-Trust-Test.

Agent-Werkzeugcontainer

diff --git a/scripts/package.sh b/scripts/package.sh index 963dada..5de32c4 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -49,8 +49,8 @@ mkdir -p "${BUILD_DIR}/usr/local/bin" mkdir -p "${BUILD_DIR}/etc/rc.d" mkdir -p "${BUILD_DIR}/usr/local/emhttp/plugins/mua" mkdir -p "${BUILD_DIR}/usr/doc/mua-${VERSION}" -cp "${ROOT}/docs/HTTPS.md" "${ROOT}/docs/HERMES.md" "${BUILD_DIR}/usr/doc/mua-${VERSION}/" -chmod 644 "${BUILD_DIR}/usr/doc/mua-${VERSION}/HTTPS.md" "${BUILD_DIR}/usr/doc/mua-${VERSION}/HERMES.md" +cp "${ROOT}/docs/HTTPS.md" "${ROOT}/docs/HERMES.md" "${ROOT}/docs/UNRAID-CERTIFICATES.md" "${BUILD_DIR}/usr/doc/mua-${VERSION}/" +chmod 644 "${BUILD_DIR}/usr/doc/mua-${VERSION}/HTTPS.md" "${BUILD_DIR}/usr/doc/mua-${VERSION}/HERMES.md" "${BUILD_DIR}/usr/doc/mua-${VERSION}/UNRAID-CERTIFICATES.md" # Binary cp "${DIST_DIR}/mua" "${BUILD_DIR}/usr/local/bin/mua" diff --git a/scripts/test-release.py b/scripts/test-release.py index 5a439e0..6bc4b9b 100644 --- a/scripts/test-release.py +++ b/scripts/test-release.py @@ -112,6 +112,11 @@ class ReleaseTests(unittest.TestCase): self.assertEqual(hashlib.sha256(archive.read_bytes()).hexdigest(), "ee85aa33230dbb6fe561f8c0000cb854bd542b0da5ad6c1a9100320fc2d5267f") + def test_r034_archive_is_not_overwritten(self): + archive = ROOT / "dist/mua-2026.11.05.r034-x86_64-1.txz" + self.assertEqual(hashlib.sha256(archive.read_bytes()).hexdigest(), + "ed6f1f52474711ac87aba9dd53d3f920c9701373bafc7eeff868ef9a839100ed") + @unittest.skipUnless(os.environ.get("MUA_RELEASE_ARCHIVE"), "set MUA_RELEASE_ARCHIVE after building") def test_built_archive_matches_manifest_and_expected_files(self): archive = Path(os.environ["MUA_RELEASE_ARCHIVE"]) @@ -136,6 +141,7 @@ class ReleaseTests(unittest.TestCase): "usr/local/bin/unraid-admin-helper.php": "scripts/unraid-admin-helper.php", f"usr/doc/mua-{version()}/HTTPS.md": "docs/HTTPS.md", f"usr/doc/mua-{version()}/HERMES.md": "docs/HERMES.md", + f"usr/doc/mua-{version()}/UNRAID-CERTIFICATES.md": "docs/UNRAID-CERTIFICATES.md", } for packaged, source in paths.items(): self.assertEqual(package.extractfile(packaged).read(), (ROOT / source).read_bytes()) diff --git a/src/admin.test.ts b/src/admin.test.ts index 4420a21..0bd173b 100644 --- a/src/admin.test.ts +++ b/src/admin.test.ts @@ -62,7 +62,7 @@ test("actual MCP transport advertises new tools and marks failed commands as err return await r.json() as any; }; const init = await rpc("initialize", { protocolVersion: "2025-03-26", capabilities: {}, clientInfo: { name: "isolated-test", version: "1" } }); - expect(init.result.serverInfo.version).toBe("2026.11.05.r034"); + expect(init.result.serverInfo.version).toBe("2026.11.05.r035"); const list = await rpc("tools/list", {}); expect(list.result.tools.some((t: { name: string }) => t.name === "unraid_share_apply")).toBe(true); const fail = await rpc("tools/call", { name: "unraid_system_shell", arguments: { command: "exit 17" } }); diff --git a/src/helpers.ts b/src/helpers.ts index 4dd28bb..63433f6 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -17,7 +17,7 @@ import { readProcessOutput } from "./process-output"; // ── Konstanten ────────────────────────────────────────────────────────── export const MUA_SERVER_NAME = "mua"; -export const MUA_VERSION = "2026.11.05.r034"; +export const MUA_VERSION = "2026.11.05.r035"; export const MUA_PROTOCOL_VERSION = "2025-03-26"; export const PHP_HELPER = "/usr/local/bin/unraid-docker-mcp-helper.php"; export const STATUS_HELPER = "/usr/local/bin/unraid-mcp-status-helper.php"; diff --git a/src/index.ts b/src/index.ts index 0a6c652..0fc3add 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,6 +36,7 @@ import { spawn } from "node:child_process"; import { appendFile, chmodSync, statSync, writeFileSync } from "node:fs"; import { ToolCallGate, withHardTimeout } from "./concurrency"; import { readTLSSettings, saveTLSSettings, tlsEnvOverride, tlsOptions, TLSConfigurationError } from "./tls"; +import { discoverUnraidCertificates, UnraidCertificateError } from "./unraid-tls"; if (process.argv.includes("--check-config")) { try { @@ -470,14 +471,19 @@ try { process.exit(1); } -function transportStatus() { +function transportStatus(forGUI = false) { let tls = activeTLS; let error: string | undefined; try { tls = readTLSSettings(); } catch { error = "Gespeicherte TLS-Konfiguration ist ungültig oder nicht lesbar; vor Neustart prüfen."; } + let unraid: { choices: { id: string; label: string }[]; error?: string } | undefined; + if (forGUI) { + try { unraid = { choices: discoverUnraidCertificates().map(({ id, label }) => ({ id, label })) }; } + catch (cause) { unraid = { choices: [], error: cause instanceof UnraidCertificateError ? cause.message : "Unraid-WebGUI-Konfiguration nicht eindeutig erkennbar." }; } + } return { scheme: activeTLS.enabled ? "https" : "http", port: PORT, tls, restartRequired: !!error || JSON.stringify(tls) !== JSON.stringify(activeTLS), - envOverride: tlsEnvOverride(), ...(error ? { error } : {}) }; + envOverride: tlsEnvOverride(), ...(unraid ? { unraid } : {}), ...(error ? { error } : {}) }; } // ── Config-Server (nur localhost:127.0.0.1:3013) ─────────────────────── @@ -544,7 +550,7 @@ try { return Response.json({ apiKeyConfigured: true, apiKeyMasked: getMaskedApiKey(), - transport: transportStatus(), + transport: transportStatus(true), enabledTools: getEnabledTools(), allToolsEnabled: getAllToolsEnabled(), allTools: TOOLS.filter((t) => !TOOLBOX_TOOL_NAMES.has(t.name)).map((t) => ({ diff --git a/src/tls.test.ts b/src/tls.test.ts index 329cc2e..bf07021 100644 --- a/src/tls.test.ts +++ b/src/tls.test.ts @@ -5,6 +5,7 @@ import { join } from "node:path"; import { connect } from "node:net"; import { request } from "node:https"; import { tlsOptions } from "./tls"; +import { unraidRoot } from "../test/unraid-fixtures"; // All listeners, certificates, tokens and tool data in this suite are synthetic. let root: string; @@ -31,6 +32,99 @@ beforeAll(() => { }); afterAll(() => rmSync(root, { recursive: true, force: true })); +test("Unraid source can be saved without manual paths and starts real verified HTTPS after explicit restart", async () => { + const fixture = unraidBundle(true); + const layout = unraidRoot("7.3.4"); + renameSync(fixture.bundle, join(layout, "boot/config/ssl/certs/tower_unraid_bundle.pem")); + const app = await start("", { MUA_UNRAID_ROOT: layout }); + let saved = ""; + try { + const token = readFileSync(join(app.dir, "admin.token"), "utf8").trim(); + const response = await fetch(`http://127.0.0.1:${app.configPort}/config`, { method: "POST", + headers: { "X-MUA-Admin-Token": token, "Content-Type": "application/json" }, + body: JSON.stringify({ tls: { enabled: true, source: "unraid", unraidChoice: "" } }) }); + expect(response.status).toBe(200); + expect(((await response.json()) as any).transport.unraid).toBeUndefined(); + saved = readFileSync(join(app.dir, "tls.conf"), "utf8"); + expect(saved).toContain("MUA_TLS_SOURCE=unraid"); + expect(saved).not.toContain("MUA_TLS_CERT_FILE"); + expect(saved).not.toContain("PRIVATE KEY"); + expect((await fetch(`http://127.0.0.1:${app.port}/health`)).status).toBe(200); + } finally { await app.stop(); } + const secure = await start(saved, { MUA_UNRAID_ROOT: layout }); + try { + expect((await bundleRequest(secure.port, "/health", fixture.publicCert)).data.version).toBe(expectedVersion); + const initialized = await bundleRequest(secure.port, "/mcp", fixture.publicCert, + { jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2025-03-26", capabilities: {}, clientInfo: { name: "unraid-mode", version: "1" } } }, testToken); + expect(initialized.status).toBe(200); + expect(initialized.data.result.serverInfo.version).toBe(expectedVersion); + const rpc = (id: number, method: string, params: unknown = {}) => bundleRequest(secure.port, "/mcp", fixture.publicCert, + { jsonrpc: "2.0", id, method, params }, testToken); + expect((await rpc(2, "tools/list")).data.result.tools.some((tool: any) => tool.name === "unraid_system_shell_readonly")).toBe(true); + const called = await rpc(3, "tools/call", { name: "unraid_system_shell_readonly", arguments: { program: "ls", args: ["-ld", layout] } }); + expect(JSON.parse(called.data.result.content[0].text).exit_code).toBe(0); + expect((await bundleRequest(secure.port, "/mcp", fixture.publicCert, { method: "ping" })).status).toBe(401); + await expect(bundleRequest(secure.port, "/health", cert)).rejects.toThrow(); + } finally { await secure.stop(); rmSync(layout, { recursive: true, force: true }); } +}, 15_000); + +test("WebGUI offers path-free Unraid mode and requires explicit choice for multiple active SNI certificates", async () => { + const local = unraidBundle(true), provisioned = unraidBundle(false); + const layout = unraidRoot("7.3.4", "yes-sni"); + renameSync(local.bundle, join(layout, "boot/config/ssl/certs/tower_unraid_bundle.pem")); + renameSync(provisioned.bundle, join(layout, "boot/config/ssl/certs/certificate_bundle.pem")); + const app = await start("", { MUA_UNRAID_ROOT: layout }); + try { + const html = renderWebGUI(app); + expect(html.includes("Unraid-WebGUI-Zertifikat verwenden")).toBe(true); + expect(html.includes('name="tls_source"')).toBe(true); + expect(html.includes("Expertenoption")).toBe(true); + const csrf = /name="mua_csrf" value="([a-f0-9]+)"/.exec(html)![1]; + const fields = { action: "save_tls", tls_enabled: "on", tls_source: "unraid", mua_csrf: csrf }; + const ambiguous = renderWebGUI(app, fields); + expect(ambiguous).toContain("Mehrere aktive"); + expect(readFileSync(join(app.dir, "tls.conf"), "utf8")).toBe(""); + const token = readFileSync(join(app.dir, "admin.token"), "utf8").trim(); + const config = await (await fetch(`http://127.0.0.1:${app.configPort}/config`, { headers: { "X-MUA-Admin-Token": token } })).json() as any; + const choice = config.transport.unraid.choices.find((item: any) => item.label.includes("test.hash.myunraid.net")); + const saved = renderWebGUI(app, { ...fields, tls_unraid_choice: choice.id }); + expect(saved).toContain("TLS-Einstellungen geprüft und gespeichert"); + expect(saved).toContain("noch nicht aktiv"); + expect(readFileSync(join(app.dir, "tls.conf"), "utf8")).toContain(`MUA_TLS_UNRAID_CERT=${choice.id}`); + expect(saved).not.toContain("-----BEGIN"); + } finally { await app.stop(); rmSync(layout, { recursive: true, force: true }); } +}, 15_000); + +test("Unraid mode never falls back to expert paths when runtime state or the selected identity is unavailable", async () => { + const layout = unraidRoot(); + const config = tlsConfig() + `MUA_TLS_SOURCE=unraid\nMUA_TLS_UNRAID_CERT=${"f".repeat(64)}\n`; + try { + for (const selectedRoot of [layout, join(layout, "missing-runtime")]) { + const app = await start(config, { MUA_UNRAID_ROOT: selectedRoot }); + try { + const code = await Promise.race([app.child.exited, Bun.sleep(1000).then(() => "still-running")]); + expect(code).not.toBe(0); + expect(code).not.toBe("still-running"); + expect(await tcpReady(app.port)).toBe(false); + expect(((await app.stdout) + (await app.stderr)).includes("PRIVATE KEY")).toBe(false); + } finally { await app.stop(); } + } + } finally { rmSync(layout, { recursive: true, force: true }); } +}, 10_000); + +test("Unraid certificate reuse is opt-in even when a valid WebGUI bundle exists", async () => { + const fixture = unraidBundle(true); + const layout = unraidRoot(); + renameSync(fixture.bundle, join(layout, "boot/config/ssl/certs/tower_unraid_bundle.pem")); + const app = await start("MUA_TLS_ENABLED=true\n", { MUA_UNRAID_ROOT: layout }); + try { + const code = await Promise.race([app.child.exited, Bun.sleep(500).then(() => "still-running")]); + expect(code).not.toBe("still-running"); + expect(code).not.toBe(0); + expect(await tcpReady(app.port)).toBe(false); + } finally { await app.stop(); rmSync(layout, { recursive: true, force: true }); } +}, 5000); + test("same-path combined PEM uses one in-memory snapshot for certificate and key", () => { const bundle = join(root, "snapshot-bundle.pem"); writeFileSync(bundle, readFileSync(key, "utf8") + readFileSync(cert, "utf8"), { mode: 0o600 }); @@ -205,7 +299,8 @@ async function start(tlsConfig: string | null, overrides: Record const entry = process.env.MUA_TEST_BINARY; const child = Bun.spawn(entry ? [entry] : [process.execPath, join(import.meta.dir, "index.ts")], { env: { ...process.env, MUA_TLS_ENABLED: undefined, MUA_TLS_CERT_FILE: undefined, - MUA_TLS_KEY_FILE: undefined, MUA_CONFIG_DIR: dir, MUA_PORT: String(port), + MUA_TLS_KEY_FILE: undefined, MUA_TLS_SOURCE: undefined, MUA_TLS_UNRAID_CERT: undefined, + MUA_UNRAID_ROOT: join(root, "no-real-unraid"), MUA_CONFIG_DIR: dir, MUA_PORT: String(port), MUA_HOST: "127.0.0.1", MUA_CONFIG_PORT: String(configPort), MUA_API_KEY: testToken, MUA_ENABLED_TOOLS: "unraid_system_shell_readonly", MUA_ADMIN_TOKEN_FILE: join(dir, "admin.token"), MUA_AUDIT_LOG: join(dir, "audit.log"), @@ -356,6 +451,7 @@ test("WebGUI enforces CSRF and saves TLS separately, with clear invalid-certific expect(saved.includes("TLS-Einstellungen geprüft und gespeichert")).toBe(true); expect(saved.includes("noch nicht aktiv")).toBe(true); const content = readFileSync(join(app.dir, "tls.conf"), "utf8"); + expect(content.includes("MUA_TLS_SOURCE")).toBe(false); // Manual file stays readable by r034. const invalid = renderWebGUI(app, { ...fields, tls_key_file: join(root, "missing.key"), mua_csrf: csrf }); expect(invalid.includes("PEM-Datei fehlt")).toBe(true); expect(readFileSync(join(app.dir, "tls.conf"), "utf8")).toBe(content); @@ -382,6 +478,7 @@ test("invalid TLS admin input never alters persisted TLS or permissions", async try { const token = readFileSync(join(app.dir, "admin.token"), "utf8").trim(); for (const tls of [null, [], { enabled: "true", certFile: cert, keyFile: key }, + { enabled: true, source: null, certFile: cert, keyFile: key }, { enabled: true, certFile: cert, keyFile: join(root, "absent.key") }, { enabled: false, certFile: cert + "\nMUA_TLS_ENABLED=true", keyFile: key }]) { const response = await fetch(`http://127.0.0.1:${app.configPort}/config`, { method: "POST", diff --git a/src/tls.ts b/src/tls.ts index 8eb8710..89ca3d8 100644 --- a/src/tls.ts +++ b/src/tls.ts @@ -2,13 +2,18 @@ import { mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } import { isAbsolute, dirname, join } from "node:path"; import { constants, randomBytes, X509Certificate } from "node:crypto"; import { createSecureContext } from "node:tls"; +import { selectUnraidCertificate, UnraidCertificateError } from "./unraid-tls"; export interface TLSSettings { enabled: boolean; certFile: string; keyFile: string; + source?: "manual" | "unraid"; + unraidChoice?: string; } +const TLS_KEYS = ["MUA_TLS_ENABLED", "MUA_TLS_CERT_FILE", "MUA_TLS_KEY_FILE", "MUA_TLS_SOURCE", "MUA_TLS_UNRAID_CERT"]; + export class TLSConfigurationError extends Error {} export function tlsConfigFile(): string { @@ -32,20 +37,29 @@ export function readTLSSettings(): TLSSettings { if (!trimmed || trimmed.startsWith("#")) continue; const eq = trimmed.indexOf("="); const name = trimmed.slice(0, eq).trim(); - if (!["MUA_TLS_ENABLED", "MUA_TLS_CERT_FILE", "MUA_TLS_KEY_FILE"].includes(name) || eq < 0) { + if (!TLS_KEYS.includes(name) || eq < 0) { throw new TLSConfigurationError("Ungültige TLS-Konfiguration (tls.conf)."); } if (name in values) throw new TLSConfigurationError("Doppelter TLS-Konfigurationseintrag."); values[name] = trimmed.slice(eq + 1).trim(); } - for (const name of ["MUA_TLS_ENABLED", "MUA_TLS_CERT_FILE", "MUA_TLS_KEY_FILE"]) { + for (const name of TLS_KEYS) { if (process.env[name] !== undefined) values[name] = process.env[name]!; } const enabled = values.MUA_TLS_ENABLED ?? "false"; if (enabled !== "true" && enabled !== "false") { throw new TLSConfigurationError("MUA_TLS_ENABLED muss true oder false sein."); } - return { enabled: enabled === "true", certFile: values.MUA_TLS_CERT_FILE ?? "", keyFile: values.MUA_TLS_KEY_FILE ?? "" }; + const certFile = values.MUA_TLS_CERT_FILE ?? "", keyFile = values.MUA_TLS_KEY_FILE ?? ""; + // Never infer Unraid reuse from missing expert paths. Only an explicit source + // opts in; leaving source unset lets the fresh GUI recommend it without use. + const source = values.MUA_TLS_SOURCE; + const unraidChoice = values.MUA_TLS_UNRAID_CERT ?? ""; + if ((source !== undefined && !["manual", "unraid"].includes(source)) || (unraidChoice && !/^[a-f0-9]{64}$/.test(unraidChoice))) { + throw new TLSConfigurationError("Ungültiger TLS-Zertifikatmodus oder WebGUI-Zertifikatauswahl."); + } + return { enabled: enabled === "true", certFile, keyFile, + ...(source !== undefined || certFile || keyFile ? { source: (source ?? "manual") as "manual" | "unraid" } : {}), unraidChoice }; } function readPEM(path: string, field: string): Buffer { @@ -62,17 +76,25 @@ function readPEM(path: string, field: string): Buffer { } export function tlsEnvOverride(): boolean { - return ["MUA_TLS_ENABLED", "MUA_TLS_CERT_FILE", "MUA_TLS_KEY_FILE"].some((name) => process.env[name] !== undefined); + return TLS_KEYS.some((name) => process.env[name] !== undefined); } export function saveTLSSettings(input: unknown): void { if (tlsEnvOverride()) throw new TLSConfigurationError("TLS wird durch Umgebungsvariablen verwaltet; WebGUI-Änderung gesperrt."); if (!input || typeof input !== "object" || Array.isArray(input)) throw new TLSConfigurationError("Ungültige TLS-Einstellungen."); const value = input as Record; - if (typeof value.enabled !== "boolean" || typeof value.certFile !== "string" || typeof value.keyFile !== "string") { - throw new TLSConfigurationError("TLS erwartet enabled (boolean), certFile und keyFile (Dateipfade)."); + const source = value.source === undefined ? "manual" : value.source; + if (typeof value.enabled !== "boolean" || (source !== "manual" && source !== "unraid") || + (source === "manual" && (typeof value.certFile !== "string" || typeof value.keyFile !== "string")) || + (value.unraidChoice !== undefined && (typeof value.unraidChoice !== "string" || (value.unraidChoice && !/^[a-f0-9]{64}$/.test(value.unraidChoice))))) { + throw new TLSConfigurationError("Ungültiger TLS-Modus oder Zertifikatseinstellungen."); + } + const settings: TLSSettings = { enabled: value.enabled, source, unraidChoice: (value.unraidChoice as string) ?? "", + certFile: source === "manual" ? value.certFile as string : "", keyFile: source === "manual" ? value.keyFile as string : "" }; + if (source === "unraid" && settings.enabled) { + try { settings.unraidChoice = selectUnraidCertificate(settings.unraidChoice).id; } + catch (error) { throw new TLSConfigurationError(error instanceof UnraidCertificateError ? error.message : "Unraid-WebGUI-Zertifikat nicht eindeutig erkennbar."); } } - const settings: TLSSettings = { enabled: value.enabled, certFile: value.certFile, keyFile: value.keyFile }; for (const path of [settings.certFile, settings.keyFile]) { if (path.length > 4096 || /[\r\n\0]/.test(path) || path !== path.trim() || (path && !isAbsolute(path))) { throw new TLSConfigurationError("TLS benötigt absolute Dateipfade ohne Steuerzeichen oder äußere Leerzeichen."); @@ -84,8 +106,9 @@ export function saveTLSSettings(input: unknown): void { try { mkdirSync(dirname(file), { recursive: true }); writeFileSync(temporary, ["# MUA TLS (separate from API key and tool permissions)", - `MUA_TLS_ENABLED=${settings.enabled}`, `MUA_TLS_CERT_FILE=${settings.certFile}`, - `MUA_TLS_KEY_FILE=${settings.keyFile}`, ""].join("\n"), { mode: 0o600, flag: "wx" }); + `MUA_TLS_ENABLED=${settings.enabled}`, + ...(source === "unraid" ? ["MUA_TLS_SOURCE=unraid", `MUA_TLS_UNRAID_CERT=${settings.unraidChoice}`] + : [`MUA_TLS_CERT_FILE=${settings.certFile}`, `MUA_TLS_KEY_FILE=${settings.keyFile}`]), ""].join("\n"), { mode: 0o600, flag: "wx" }); renameSync(temporary, file); } catch { throw new TLSConfigurationError("TLS-Konfiguration konnte nicht gespeichert werden."); @@ -96,12 +119,17 @@ export function saveTLSSettings(input: unknown): void { export function tlsOptions(settings: TLSSettings): Bun.TLSOptions | undefined { if (!settings.enabled) return undefined; - const cert = readPEM(settings.certFile, "MUA_TLS_CERT_FILE"); + let { certFile, keyFile } = settings; + if (settings.source === "unraid") { + try { ({ certFile, keyFile } = selectUnraidCertificate(settings.unraidChoice)); } + catch (error) { throw new TLSConfigurationError(error instanceof UnraidCertificateError ? error.message : "Unraid-WebGUI-Zertifikat nicht eindeutig erkennbar."); } + } + const cert = readPEM(certFile, "MUA_TLS_CERT_FILE"); // Unraid may keep both in one PEM. Reuse one read/snapshot so replacing // that bundle cannot pair a certificate from one version with a new key. - const key = settings.keyFile === settings.certFile + const key = keyFile === certFile ? cert - : readPEM(settings.keyFile, "MUA_TLS_KEY_FILE"); + : readPEM(keyFile, "MUA_TLS_KEY_FILE"); try { // Validates PEM, unencrypted key and matching certificate/key pair before // opening any listener. Raw library errors can include PEM; never expose them. diff --git a/src/unraid-tls.test.ts b/src/unraid-tls.test.ts new file mode 100644 index 0000000..acbdead --- /dev/null +++ b/src/unraid-tls.test.ts @@ -0,0 +1,111 @@ +import { afterAll, expect, test } from "bun:test"; +import { existsSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { discoverUnraidCertificates, selectUnraidCertificate } from "./unraid-tls"; +import { unraidRoot } from "../test/unraid-fixtures"; + +const roots: string[] = []; +const fixture = (version?: string, scenario?: string, config?: string) => { + const root = unraidRoot(version, scenario, config); roots.push(root); return root; +}; +afterAll(() => roots.forEach(root => rmSync(root, { recursive: true, force: true }))); + +test("Unraid WebGUI selection follows the effective nginx directive, not another bundle on disk", () => { + const root = fixture(); + const choices = discoverUnraidCertificates(root); + expect(choices).toHaveLength(1); + expect(choices[0]!.certFile).toBe(join(root, "boot/config/ssl/certs/tower_unraid_bundle.pem")); + expect(choices[0]!.keyFile).toBe(choices[0]!.certFile); + expect(choices[0]!.label).toContain("tower.local"); +}); + +const versions = ["7.0.0", "7.1.0", "7.2.0", "7.3.4", "7.4.0-rc.2.5"]; +for (const version of versions) { + for (const [scenario, count] of [["yes-local", 1], ["yes-sni", 2], ["auto-sni", 1], ["no-local", 0], ["no-sni", 1]] as const) { + test(`publisher-generated ${version} ${scenario} resolves only serving WebGUI certificates`, () => { + const root = fixture(version, scenario); + if (!count) { expect(() => discoverUnraidCertificates(root)).toThrow("Keine aktive HTTPS-WebGUI"); return; } + const choices = discoverUnraidCertificates(root); + expect(choices).toHaveLength(count); + expect(choices.some(choice => choice.certFile.endsWith("unused-newest.pem"))).toBe(false); + if (scenario === "auto-sni" || scenario === "no-sni") { + // Default self-signed 404 servers are NOT a working WebGUI endpoint. + expect(choices[0]!.certFile).toEndWith("certificate_bundle.pem"); + expect(choices[0]!.label).toContain("test.hash.myunraid.net"); + } + }); + } +} + +test("multiple SNI identities require a choice, never the first/default/newest file", () => { + const root = fixture("7.3.4", "yes-sni"); + expect(() => selectUnraidCertificate("", root)).toThrow("Mehrere aktive"); + const choices = discoverUnraidCertificates(root); + const publicChoice = choices.find(choice => choice.certFile.endsWith("certificate_bundle.pem"))!; + expect(selectUnraidCertificate(publicChoice.id, root).certFile).toBe(publicChoice.certFile); + expect(() => selectUnraidCertificate("f".repeat(64), root)).toThrow("nicht mehr aktiv"); +}); + +test("nginx include globs and quoted paths are parsed as data", () => { + const root = fixture(); + writeFileSync(join(root, "etc/nginx/nginx.conf"), 'http { include "/etc/nginx/conf.d/*.conf"; }'); + const file = join(root, "etc/nginx/conf.d/servers.conf"); + writeFileSync(file, readFileSync(file, "utf8").replaceAll("/boot/config/ssl/certs/tower_unraid_bundle.pem", '"/boot/config/ssl/certs/tower_unraid_bundle.pem"')); + expect(discoverUnraidCertificates(root)).toHaveLength(1); +}); + +for (const config of [ + 'http { include /outside/nginx.conf; }', + 'http { include /etc/nginx/../not-nginx/file.conf; }', + 'http { include /etc/nginx/nginx.conf; }', + 'http { include $config; }', + 'http { server { listen 443 ssl; ', +]) { + test(`unsafe or malformed nginx includes fail closed: ${config.slice(0, 40)}`, () => { + const root = fixture(); + writeFileSync(join(root, "etc/nginx/nginx.conf"), config); + expect(() => discoverUnraidCertificates(root)).toThrow(); + }); +} + +test("different cert/key paths or dynamic certificates need expert configuration", () => { + const root = fixture(); + const file = join(root, "etc/nginx/conf.d/servers.conf"); + const original = readFileSync(file, "utf8"); + writeFileSync(file, original.replace(/(ssl_certificate_key\s+)\S+;/, "$1/boot/config/ssl/certs/certificate_bundle.pem;")); + expect(() => discoverUnraidCertificates(root)).toThrow(); + writeFileSync(file, original.replaceAll("/boot/config/ssl/certs/tower_unraid_bundle.pem", "$dynamic.pem")); + expect(() => discoverUnraidCertificates(root)).toThrow(); +}); + +test("unrecognized runtime mode/version and shell syntax are never executed or guessed", () => { + const root = fixture(); + const state = join(root, "var/local/emhttp/nginx.ini"); + const original = readFileSync(state, "utf8"); + writeFileSync(state, original.replace('"yes"', '"unexpected"')); + expect(() => discoverUnraidCertificates(root)).toThrow(); + const marker = join(root, "must-not-exist"); + writeFileSync(state, original.replace('"yes"', `"$(touch ${marker})"`)); + expect(() => discoverUnraidCertificates(root)).toThrow(); + expect(existsSync(marker)).toBe(false); + writeFileSync(state, original); + writeFileSync(join(root, "etc/unraid-version"), 'version="8.0.0"\n'); + expect(() => discoverUnraidCertificates(root)).toThrow("Unraid-7.0"); +}); + +test("custom server-level routing cannot silently remove an identity and select the other SNI bundle", () => { + const root = fixture("7.3.4", "yes-sni"); + const path = join(root, "etc/nginx/conf.d/servers.conf"); + const original = readFileSync(path, "utf8"); + for (const directive of ['return 200 "maintenance";', 'if ($maintenance) { return 503; }', 'break;', 'rewrite ^ /other last;']) { + writeFileSync(path, original.replace(/ssl_certificate\s+/, directive + "\nssl_certificate ")); + expect(() => discoverUnraidCertificates(root)).toThrow(); + } +}); + +test("certificate symlink outside the Unraid cert directory is not automatically followed", () => { + const root = fixture(); + const file = join(root, "boot/config/ssl/certs/tower_unraid_bundle.pem"); + rmSync(file); symlinkSync(join(root, "etc/unraid-version"), file); + expect(() => discoverUnraidCertificates(root)).toThrow(); +}); diff --git a/src/unraid-tls.ts b/src/unraid-tls.ts new file mode 100644 index 0000000..568251d --- /dev/null +++ b/src/unraid-tls.ts @@ -0,0 +1,163 @@ +import { readFileSync, readdirSync, realpathSync, statSync } from "node:fs"; +import { isAbsolute, join, posix, resolve, sep } from "node:path"; +import { createHash } from "node:crypto"; + +export class UnraidCertificateError extends Error {} +export interface UnraidCertificateChoice { id: string; label: string; certFile: string; keyFile: string } +interface Directive { name: string; args: string[]; body?: Directive[] } +const unclear = () => new UnraidCertificateError("Unraid-nginx-Konfiguration nicht eindeutig unterstützt. Management Access prüfen oder den Expertenmodus verwenden."); + +// Parse data only: never source ident.cfg/nginx.ini or invoke nginx/rc.nginx. +function ini(text: string, keys: string[]): Record { + const result: Record = {}; + for (const line of text.replace(/^\uFEFF/, "").split(/\r?\n/)) { + const match = /^\s*([A-Za-z_][A-Za-z_0-9]*)\s*=\s*(.*?)\s*$/.exec(line); + if (!match || !keys.includes(match[1]!)) continue; + if (Object.hasOwn(result, match[1]!)) throw unclear(); + let value = match[2]!; + if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) value = value.slice(1, -1); + if (/[\x00-\x1f$`\\'";]/.test(value)) throw unclear(); + result[match[1]!] = value; + } + return result; +} + +function parse(text: string): Directive[] { + const tokens: string[] = []; + let word = "", quote = "", pending = false; + const flush = () => { if (pending) tokens.push(word); word = ""; pending = false; }; + for (let i = 0; i < text.length; i++) { + const char = text[i]!; + if (char === "\\") { + if (++i >= text.length) throw unclear(); + word += text[i]; pending = true; + } else if (quote) { + if (char === quote) quote = ""; else word += char; + } else if (char === '"' || char === "'") { + quote = char; pending = true; + } else if (char === "#") { + flush(); while (i < text.length && text[i] !== "\n") i++; + } else if (/\s/.test(char)) flush(); + else if ("{};".includes(char)) { flush(); tokens.push(char); } + else { word += char; pending = true; } + if (tokens.length > 100_000) throw unclear(); + } + if (quote) throw unclear(); + flush(); + let index = 0; + function block(depth: number): Directive[] { + if (depth > 24) throw unclear(); + const nodes: Directive[] = []; + while (index < tokens.length) { + if (tokens[index] === "}") { + if (!depth) throw unclear(); + index++; return nodes; + } + const words: string[] = []; + while (index < tokens.length && ![";", "{", "}"].includes(tokens[index]!)) words.push(tokens[index++]!); + const end = tokens[index++]; + if (!words.length || (end !== ";" && end !== "{")) throw unclear(); + nodes.push({ name: words[0]!, args: words.slice(1), ...(end === "{" ? { body: block(depth + 1) } : {}) }); + } + if (depth) throw unclear(); + return nodes; + } + return block(0); +} + +export function discoverUnraidCertificates(root = process.env.MUA_UNRAID_ROOT ?? "/"): UnraidCertificateChoice[] { + const base = resolve(root); + const physical = (logical: string) => join(base, logical.slice(1)); + const checkedReal = (logical: string, directory: string) => { + const file = realpathSync(physical(logical)); + const parent = realpathSync(physical(directory)); + if (!file.startsWith(parent + sep)) throw unclear(); + return file; + }; + const text = (logical: string) => { + try { + const file = physical(logical); + const info = statSync(file); + if (!info.isFile() || info.size > 1_048_576) throw unclear(); + return readFileSync(file, "utf8"); + } catch { throw new UnraidCertificateError("Unraid-WebGUI-Laufzeitkonfiguration nicht lesbar. WebGUI muss gestartet sein; keine Zertifikatsdatei wird geraten."); } + }; + const version = ini(text("/etc/unraid-version"), ["version"]).version; + if (!version || !/^7\.[0-4]\.\d+(?:-[a-zA-Z0-9.]+)?$/.test(version)) { + throw new UnraidCertificateError("Unraid-Zertifikatauswahl unterstützt die geprüften Unraid-7.0–7.4-Konfigurationsformate; für andere Versionen Expertenmodus verwenden."); + } + const runtime = ini(text("/var/local/emhttp/nginx.ini"), ["NGINX_USESSL", "NGINX_LANMDNS", "NGINX_PORTSSL"]); + if (!["no", "yes", "auto"].includes(runtime.NGINX_USESSL ?? "") || !/^\d{1,5}$/.test(runtime.NGINX_PORTSSL ?? "") || + Number(runtime.NGINX_PORTSSL) < 1 || Number(runtime.NGINX_PORTSSL) > 65535) throw unclear(); + if (!/^[a-zA-Z0-9_.-]+$/.test(runtime.NGINX_LANMDNS ?? "")) throw unclear(); + const candidates = new Map(); + const visited = new Set(); + function includes(pattern: string): string[] { + const logical = isAbsolute(pattern) ? pattern : posix.join("/etc/nginx", pattern); + if (!logical.startsWith("/etc/nginx/") || /[\x00-\x20$`{}\[\]]/.test(logical) || logical.split("/").includes("..")) throw unclear(); + const directory = posix.dirname(logical), filename = posix.basename(logical); + if (/[*?]/.test(directory)) throw unclear(); + if (!/[*?]/.test(filename)) return [logical]; + const expression = new RegExp("^" + filename.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("*", ".*").replaceAll("?", ".") + "$"); + return readdirSync(physical(directory)).filter(name => expression.test(name)).sort().map(name => posix.join(directory, name)); + } + function walk(nodes: Directive[], context: "main" | "http", depth: number) { + if (depth > 12) throw unclear(); + for (const node of nodes) { + if (node.name === "include" && !node.body) { + if (node.args.length !== 1) throw unclear(); + for (const file of includes(node.args[0]!)) load(file, context, depth + 1); + } else if (node.name === "http" && node.body && context === "main") walk(node.body, "http", depth); + else if (node.name === "server" && node.body && context === "http") inspect(node.body); + } + } + function inspect(nodes: Directive[]) { + // Only actual WebGUI servers include this location file. Exclude SSL 404 + // defaults, redirects, other applications and unused certificates on disk. + if (!nodes.some(node => node.name === "include" && node.args.length === 1 && node.args[0] === "/etc/nginx/conf.d/locations.conf")) return; + if (!nodes.some(node => node.name === "listen" && node.args.includes("ssl") && + Number(node.args[0]?.split(":").at(-1)) === Number(runtime.NGINX_PORTSSL))) return; + // The publisher's real 404/redirect defaults have no WebGUI locations + // include and were excluded above. Custom server-wide control flow in a + // serving block is ambiguous; never drop it and silently pick another SNI. + if (nodes.some(node => ["return", "if", "rewrite", "break"].includes(node.name))) { + throw new UnraidCertificateError("Eigene serverweite nginx-Weiterleitung/Bedingung im WebGUI-Block: keine sichere automatische Auswahl. Konfiguration prüfen oder Expertenmodus verwenden."); + } + const certs = nodes.filter(node => node.name === "ssl_certificate"); + const keys = nodes.filter(node => node.name === "ssl_certificate_key"); + if (certs.length !== 1 || keys.length !== 1 || certs[0]!.args.length !== 1 || keys[0]!.args.length !== 1) throw unclear(); + const logical = certs[0]!.args[0]!; + if (keys[0]!.args[0] !== logical || !logical.startsWith("/boot/config/ssl/certs/") || + logical.split("/").includes("..") || /[\x00-\x20$`]/.test(logical)) throw unclear(); + const certFile = checkedReal(logical, "/boot/config/ssl/certs"); + if (!statSync(certFile).isFile()) throw unclear(); + const names = nodes.filter(node => node.name === "server_name").flatMap(node => node.args); + if (names.some(name => !/^[a-zA-Z0-9_.*:-]+$/.test(name))) throw unclear(); + const label = names.length ? names.join(", ") : `WebGUI ${runtime.NGINX_LANMDNS} (Standard)`; + const id = createHash("sha256").update(logical).digest("hex"); + const previous = candidates.get(id); + candidates.set(id, { id, label: previous && previous.label !== label ? previous.label + "; " + label : label, certFile, keyFile: certFile }); + } + function load(logical: string, context: "main" | "http", depth: number) { + const file = checkedReal(logical, "/etc/nginx"); + const marker = context + ":" + file; + if (visited.has(marker) || visited.size >= 64) throw unclear(); + visited.add(marker); + walk(parse(text(logical)), context, depth); + } + try { load("/etc/nginx/nginx.conf", "main", 0); } + catch (error) { if (error instanceof UnraidCertificateError) throw error; throw unclear(); } + if (!candidates.size) throw new UnraidCertificateError("Keine aktive HTTPS-WebGUI mit eindeutigem PEM-Bundle erkannt. Management Access prüfen; vorhandene Dateien allein werden nicht ausgewählt."); + return [...candidates.values()].sort((a, b) => a.label.localeCompare(b.label)); +} + +export function selectUnraidCertificate(id = "", root?: string): UnraidCertificateChoice { + const choices = discoverUnraidCertificates(root); + if (id) { + const choice = choices.find(candidate => candidate.id === id); + if (!choice) throw new UnraidCertificateError("Die gewählte WebGUI-Zertifikatidentität ist nicht mehr aktiv. Auswahl prüfen und ausdrücklich neu speichern."); + return choice; + } + if (choices.length !== 1) throw new UnraidCertificateError("Mehrere aktive WebGUI-/SNI-Zertifikate: bitte den gewünschten WebGUI-Zugriffsnamen auswählen."); + return choices[0]!; +} diff --git a/test/fixtures/unraid-webgui/7.0.0/auto-sni.conf b/test/fixtures/unraid-webgui/7.0.0/auto-sni.conf new file mode 100644 index 0000000..09dd9b1 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.0.0/auto-sni.conf @@ -0,0 +1,70 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://lan-ip.hash.myunraid.net +# ex: http://192.168.1.100 -> https://lan-ip.hash.myunraid.net +# +server { listen 80; return 302 https://tower.local; } +# +# Return 404 (Not Found) as default ssl action, using self-signed cert +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.0.0/no-local.conf b/test/fixtures/unraid-webgui/7.0.0/no-local.conf new file mode 100644 index 0000000..81496b8 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.0.0/no-local.conf @@ -0,0 +1,40 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.0.0/no-sni.conf b/test/fixtures/unraid-webgui/7.0.0/no-sni.conf new file mode 100644 index 0000000..6516a43 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.0.0/no-sni.conf @@ -0,0 +1,78 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Return 404 (Not Found) as default ssl action +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.0.0/yes-local.conf b/test/fixtures/unraid-webgui/7.0.0/yes-local.conf new file mode 100644 index 0000000..b89a70f --- /dev/null +++ b/test/fixtures/unraid-webgui/7.0.0/yes-local.conf @@ -0,0 +1,51 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } diff --git a/test/fixtures/unraid-webgui/7.0.0/yes-sni.conf b/test/fixtures/unraid-webgui/7.0.0/yes-sni.conf new file mode 100644 index 0000000..5a244ff --- /dev/null +++ b/test/fixtures/unraid-webgui/7.0.0/yes-sni.conf @@ -0,0 +1,72 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.1.0/auto-sni.conf b/test/fixtures/unraid-webgui/7.1.0/auto-sni.conf new file mode 100644 index 0000000..c6bcf40 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.1.0/auto-sni.conf @@ -0,0 +1,71 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://lan-ip.hash.myunraid.net +# ex: http://192.168.1.100 -> https://lan-ip.hash.myunraid.net +# +server { listen 80; return 302 https://tower.local; } +# +# Return 404 (Not Found) as default ssl action, using self-signed cert +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.1.0/no-local.conf b/test/fixtures/unraid-webgui/7.1.0/no-local.conf new file mode 100644 index 0000000..a967e51 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.1.0/no-local.conf @@ -0,0 +1,41 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.1.0/no-sni.conf b/test/fixtures/unraid-webgui/7.1.0/no-sni.conf new file mode 100644 index 0000000..866295b --- /dev/null +++ b/test/fixtures/unraid-webgui/7.1.0/no-sni.conf @@ -0,0 +1,79 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Return 404 (Not Found) as default ssl action +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.1.0/yes-local.conf b/test/fixtures/unraid-webgui/7.1.0/yes-local.conf new file mode 100644 index 0000000..fecd9e6 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.1.0/yes-local.conf @@ -0,0 +1,52 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } diff --git a/test/fixtures/unraid-webgui/7.1.0/yes-sni.conf b/test/fixtures/unraid-webgui/7.1.0/yes-sni.conf new file mode 100644 index 0000000..70acf43 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.1.0/yes-sni.conf @@ -0,0 +1,73 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.2.0/auto-sni.conf b/test/fixtures/unraid-webgui/7.2.0/auto-sni.conf new file mode 100644 index 0000000..c6bcf40 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.2.0/auto-sni.conf @@ -0,0 +1,71 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://lan-ip.hash.myunraid.net +# ex: http://192.168.1.100 -> https://lan-ip.hash.myunraid.net +# +server { listen 80; return 302 https://tower.local; } +# +# Return 404 (Not Found) as default ssl action, using self-signed cert +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.2.0/no-local.conf b/test/fixtures/unraid-webgui/7.2.0/no-local.conf new file mode 100644 index 0000000..a967e51 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.2.0/no-local.conf @@ -0,0 +1,41 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.2.0/no-sni.conf b/test/fixtures/unraid-webgui/7.2.0/no-sni.conf new file mode 100644 index 0000000..866295b --- /dev/null +++ b/test/fixtures/unraid-webgui/7.2.0/no-sni.conf @@ -0,0 +1,79 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Return 404 (Not Found) as default ssl action +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.2.0/yes-local.conf b/test/fixtures/unraid-webgui/7.2.0/yes-local.conf new file mode 100644 index 0000000..fecd9e6 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.2.0/yes-local.conf @@ -0,0 +1,52 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } diff --git a/test/fixtures/unraid-webgui/7.2.0/yes-sni.conf b/test/fixtures/unraid-webgui/7.2.0/yes-sni.conf new file mode 100644 index 0000000..70acf43 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.2.0/yes-sni.conf @@ -0,0 +1,73 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.3.4/auto-sni.conf b/test/fixtures/unraid-webgui/7.3.4/auto-sni.conf new file mode 100644 index 0000000..e256779 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.3.4/auto-sni.conf @@ -0,0 +1,78 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://lan-ip.hash.myunraid.net +# ex: http://192.168.1.100 -> https://lan-ip.hash.myunraid.net +# +server { listen 80; return 302 https://tower.local; } +# +# Return 404 (Not Found) as default ssl action, using self-signed cert +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.3.4/no-local.conf b/test/fixtures/unraid-webgui/7.3.4/no-local.conf new file mode 100644 index 0000000..40ea748 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.3.4/no-local.conf @@ -0,0 +1,48 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.3.4/no-sni.conf b/test/fixtures/unraid-webgui/7.3.4/no-sni.conf new file mode 100644 index 0000000..67fdc19 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.3.4/no-sni.conf @@ -0,0 +1,86 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Return 404 (Not Found) as default ssl action +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.3.4/yes-local.conf b/test/fixtures/unraid-webgui/7.3.4/yes-local.conf new file mode 100644 index 0000000..911ed6a --- /dev/null +++ b/test/fixtures/unraid-webgui/7.3.4/yes-local.conf @@ -0,0 +1,59 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } diff --git a/test/fixtures/unraid-webgui/7.3.4/yes-sni.conf b/test/fixtures/unraid-webgui/7.3.4/yes-sni.conf new file mode 100644 index 0000000..226fef5 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.3.4/yes-sni.conf @@ -0,0 +1,80 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.4.0-rc.2.5/auto-sni.conf b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/auto-sni.conf new file mode 100644 index 0000000..d936464 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/auto-sni.conf @@ -0,0 +1,102 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + # Capture task output at the publisher boundary. Existing plugin scripts + # (including Community Apps and plugin_rm) POST directly to /pub/plugins + # and never call WebGUI's publish(), so this hook is the only common path + # for both legacy and first-party publishers. + location ~ ^/pub/(plugins|docker|vmaction)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + nchan_publisher_upstream_request /task-capture; + } + location = /task-capture { + internal; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/emhttp/plugins/dynamix/include/TaskCapture.php; + fastcgi_param SCRIPT_NAME /plugins/dynamix/include/TaskCapture.php; + fastcgi_param REQUEST_URI "/task-capture/$nchan_channel_id"; + # Nchan forwards the published message as the request body. Use GET + # for the internal FastCGI hop so the global browser-facing CSRF + # check does not reject this trusted, non-browser request. + fastcgi_param REQUEST_METHOD GET; + fastcgi_param QUERY_STRING "type=$nchan_channel_id"; + fastcgi_param HTTP_X_TASK_CAPTURE 1; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://lan-ip.hash.myunraid.net +# ex: http://192.168.1.100 -> https://lan-ip.hash.myunraid.net +# +server { listen 80; return 302 https://tower.local; } +# +# Return 404 (Not Found) as default ssl action, using self-signed cert +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-local.conf b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-local.conf new file mode 100644 index 0000000..a7722a6 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-local.conf @@ -0,0 +1,72 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + # Capture task output at the publisher boundary. Existing plugin scripts + # (including Community Apps and plugin_rm) POST directly to /pub/plugins + # and never call WebGUI's publish(), so this hook is the only common path + # for both legacy and first-party publishers. + location ~ ^/pub/(plugins|docker|vmaction)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + nchan_publisher_upstream_request /task-capture; + } + location = /task-capture { + internal; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/emhttp/plugins/dynamix/include/TaskCapture.php; + fastcgi_param SCRIPT_NAME /plugins/dynamix/include/TaskCapture.php; + fastcgi_param REQUEST_URI "/task-capture/$nchan_channel_id"; + # Nchan forwards the published message as the request body. Use GET + # for the internal FastCGI hop so the global browser-facing CSRF + # check does not reject this trusted, non-browser request. + fastcgi_param REQUEST_METHOD GET; + fastcgi_param QUERY_STRING "type=$nchan_channel_id"; + fastcgi_param HTTP_X_TASK_CAPTURE 1; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-sni.conf b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-sni.conf new file mode 100644 index 0000000..ecf02b1 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-sni.conf @@ -0,0 +1,110 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + # Capture task output at the publisher boundary. Existing plugin scripts + # (including Community Apps and plugin_rm) POST directly to /pub/plugins + # and never call WebGUI's publish(), so this hook is the only common path + # for both legacy and first-party publishers. + location ~ ^/pub/(plugins|docker|vmaction)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + nchan_publisher_upstream_request /task-capture; + } + location = /task-capture { + internal; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/emhttp/plugins/dynamix/include/TaskCapture.php; + fastcgi_param SCRIPT_NAME /plugins/dynamix/include/TaskCapture.php; + fastcgi_param REQUEST_URI "/task-capture/$nchan_channel_id"; + # Nchan forwards the published message as the request body. Use GET + # for the internal FastCGI hop so the global browser-facing CSRF + # check does not reject this trusted, non-browser request. + fastcgi_param REQUEST_METHOD GET; + fastcgi_param QUERY_STRING "type=$nchan_channel_id"; + fastcgi_param HTTP_X_TASK_CAPTURE 1; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for http protocol +# ex: http://tower (IP address resolved via NetBIOS) +# ex: http://tower.local (IP address resolved via mDNS) +# ex: http://192.168.1.100 +# ex: http://[::ffff:192.168.1.100] +# +server { + listen 192.0.2.10:80 default_server; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + location ~ /wsproxy/80/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Return 404 (Not Found) as default ssl action +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + return 404; +} +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-local.conf b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-local.conf new file mode 100644 index 0000000..179173a --- /dev/null +++ b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-local.conf @@ -0,0 +1,83 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + # Capture task output at the publisher boundary. Existing plugin scripts + # (including Community Apps and plugin_rm) POST directly to /pub/plugins + # and never call WebGUI's publish(), so this hook is the only common path + # for both legacy and first-party publishers. + location ~ ^/pub/(plugins|docker|vmaction)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + nchan_publisher_upstream_request /task-capture; + } + location = /task-capture { + internal; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/emhttp/plugins/dynamix/include/TaskCapture.php; + fastcgi_param SCRIPT_NAME /plugins/dynamix/include/TaskCapture.php; + fastcgi_param REQUEST_URI "/task-capture/$nchan_channel_id"; + # Nchan forwards the published message as the request body. Use GET + # for the internal FastCGI hop so the global browser-facing CSRF + # check does not reject this trusted, non-browser request. + fastcgi_param REQUEST_METHOD GET; + fastcgi_param QUERY_STRING "type=$nchan_channel_id"; + fastcgi_param HTTP_X_TASK_CAPTURE 1; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } diff --git a/test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-sni.conf b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-sni.conf new file mode 100644 index 0000000..c76e1b2 --- /dev/null +++ b/test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-sni.conf @@ -0,0 +1,104 @@ +# +# Listen on local socket for nchan publishers +# +server { + listen unix:/var/run/nginx.socket default_server; + # filemanager should not display outdated messages + location = /pub/filemanager { + nchan_publisher; + nchan_channel_id "filemanager"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 30s; + } + # Capture task output at the publisher boundary. Existing plugin scripts + # (including Community Apps and plugin_rm) POST directly to /pub/plugins + # and never call WebGUI's publish(), so this hook is the only common path + # for both legacy and first-party publishers. + location ~ ^/pub/(plugins|docker|vmaction)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + nchan_publisher_upstream_request /task-capture; + } + location = /task-capture { + internal; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/emhttp/plugins/dynamix/include/TaskCapture.php; + fastcgi_param SCRIPT_NAME /plugins/dynamix/include/TaskCapture.php; + fastcgi_param REQUEST_URI "/task-capture/$nchan_channel_id"; + # Nchan forwards the published message as the request body. Use GET + # for the internal FastCGI hop so the global browser-facing CSRF + # check does not reject this trusted, non-browser request. + fastcgi_param REQUEST_METHOD GET; + fastcgi_param QUERY_STRING "type=$nchan_channel_id"; + fastcgi_param HTTP_X_TASK_CAPTURE 1; + } + location ~ /pub/(.*)$ { + nchan_publisher; + nchan_channel_id "$1"; + nchan_message_buffer_length $arg_buffer_length; + nchan_message_timeout 0; + } + location ~ /nchan_stub_status$ { + nchan_stub_status; + } +} +# +# Always accept http requests from localhost +# ex: http://localhost +# ex: http://127.0.0.1 +# ex: http://[::1] +# +server { + listen 127.0.0.1:80; + # + add_header Content-Security-Policy "frame-ancestors 'self' "; + include /etc/nginx/conf.d/locations.conf; +} +# +# Port settings for https protocol (self-signed cert) +# ex: https://tower.local +# +server { + listen 192.0.2.10:443 ssl default_server; + http2 on; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/tower_unraid_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/tower_unraid_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} +# +# Redirect http requests to https +# ex: http://tower.local -> https://tower.local +# +server { listen 80; return 302 https://tower.local; } +# +# Port settings for https using CA-signed cert +# ex: https://lan-ip.hash.myunraid.net +# +server { + listen 192.0.2.10:443 ssl; + http2 on; + server_name test.hash.myunraid.net; + add_header Content-Security-Policy "frame-ancestors 'self' "; + # Ok to use concatenated pem files; nginx will do the right thing. + ssl_certificate /boot/config/ssl/certs/certificate_bundle.pem; + ssl_certificate_key /boot/config/ssl/certs/certificate_bundle.pem; + ssl_trusted_certificate /boot/config/ssl/certs/certificate_bundle.pem; + # + # OCSP stapling + ssl_stapling off; + ssl_stapling_verify off; + # + location ~ /wsproxy/443/ { return 403; } + include /etc/nginx/conf.d/locations.conf; +} diff --git a/test/fixtures/unraid-webgui/provenance.json b/test/fixtures/unraid-webgui/provenance.json new file mode 100644 index 0000000..08ed658 --- /dev/null +++ b/test/fixtures/unraid-webgui/provenance.json @@ -0,0 +1,202 @@ +[ + { + "version": "7.0.0", + "scenario": "yes-local", + "fixture": "test/fixtures/unraid-webgui/7.0.0/yes-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/71a85f020b9b1bce48b5bec75d69d78a57d8df3d/etc/rc.d/rc.nginx", + "source_sha256": "784543e6cba1c66a2f85b29386c045a7cfd3f74e7035f6510f781d7838cb7f84", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.0.0", + "scenario": "yes-sni", + "fixture": "test/fixtures/unraid-webgui/7.0.0/yes-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/71a85f020b9b1bce48b5bec75d69d78a57d8df3d/etc/rc.d/rc.nginx", + "source_sha256": "784543e6cba1c66a2f85b29386c045a7cfd3f74e7035f6510f781d7838cb7f84", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.0.0", + "scenario": "auto-sni", + "fixture": "test/fixtures/unraid-webgui/7.0.0/auto-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/71a85f020b9b1bce48b5bec75d69d78a57d8df3d/etc/rc.d/rc.nginx", + "source_sha256": "784543e6cba1c66a2f85b29386c045a7cfd3f74e7035f6510f781d7838cb7f84", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.0.0", + "scenario": "no-local", + "fixture": "test/fixtures/unraid-webgui/7.0.0/no-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/71a85f020b9b1bce48b5bec75d69d78a57d8df3d/etc/rc.d/rc.nginx", + "source_sha256": "784543e6cba1c66a2f85b29386c045a7cfd3f74e7035f6510f781d7838cb7f84", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.0.0", + "scenario": "no-sni", + "fixture": "test/fixtures/unraid-webgui/7.0.0/no-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/71a85f020b9b1bce48b5bec75d69d78a57d8df3d/etc/rc.d/rc.nginx", + "source_sha256": "784543e6cba1c66a2f85b29386c045a7cfd3f74e7035f6510f781d7838cb7f84", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.1.0", + "scenario": "yes-local", + "fixture": "test/fixtures/unraid-webgui/7.1.0/yes-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/93e1ce11c59494b408dc8b0be250f8d4bdab5290/etc/rc.d/rc.nginx", + "source_sha256": "65b2f8911faf0de163669fe20724d192699aa3f71ae578efb408828444d9aa5d", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.1.0", + "scenario": "yes-sni", + "fixture": "test/fixtures/unraid-webgui/7.1.0/yes-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/93e1ce11c59494b408dc8b0be250f8d4bdab5290/etc/rc.d/rc.nginx", + "source_sha256": "65b2f8911faf0de163669fe20724d192699aa3f71ae578efb408828444d9aa5d", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.1.0", + "scenario": "auto-sni", + "fixture": "test/fixtures/unraid-webgui/7.1.0/auto-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/93e1ce11c59494b408dc8b0be250f8d4bdab5290/etc/rc.d/rc.nginx", + "source_sha256": "65b2f8911faf0de163669fe20724d192699aa3f71ae578efb408828444d9aa5d", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.1.0", + "scenario": "no-local", + "fixture": "test/fixtures/unraid-webgui/7.1.0/no-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/93e1ce11c59494b408dc8b0be250f8d4bdab5290/etc/rc.d/rc.nginx", + "source_sha256": "65b2f8911faf0de163669fe20724d192699aa3f71ae578efb408828444d9aa5d", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.1.0", + "scenario": "no-sni", + "fixture": "test/fixtures/unraid-webgui/7.1.0/no-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/93e1ce11c59494b408dc8b0be250f8d4bdab5290/etc/rc.d/rc.nginx", + "source_sha256": "65b2f8911faf0de163669fe20724d192699aa3f71ae578efb408828444d9aa5d", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.2.0", + "scenario": "yes-local", + "fixture": "test/fixtures/unraid-webgui/7.2.0/yes-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/1018244c1f0d525b3a9229b7ea597d315cc77120/etc/rc.d/rc.nginx", + "source_sha256": "a1eef46c82f517fb97c542d9ad18d6302346bc3f06cb115f2556b48f93e1561f", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.2.0", + "scenario": "yes-sni", + "fixture": "test/fixtures/unraid-webgui/7.2.0/yes-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/1018244c1f0d525b3a9229b7ea597d315cc77120/etc/rc.d/rc.nginx", + "source_sha256": "a1eef46c82f517fb97c542d9ad18d6302346bc3f06cb115f2556b48f93e1561f", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.2.0", + "scenario": "auto-sni", + "fixture": "test/fixtures/unraid-webgui/7.2.0/auto-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/1018244c1f0d525b3a9229b7ea597d315cc77120/etc/rc.d/rc.nginx", + "source_sha256": "a1eef46c82f517fb97c542d9ad18d6302346bc3f06cb115f2556b48f93e1561f", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.2.0", + "scenario": "no-local", + "fixture": "test/fixtures/unraid-webgui/7.2.0/no-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/1018244c1f0d525b3a9229b7ea597d315cc77120/etc/rc.d/rc.nginx", + "source_sha256": "a1eef46c82f517fb97c542d9ad18d6302346bc3f06cb115f2556b48f93e1561f", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.2.0", + "scenario": "no-sni", + "fixture": "test/fixtures/unraid-webgui/7.2.0/no-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/1018244c1f0d525b3a9229b7ea597d315cc77120/etc/rc.d/rc.nginx", + "source_sha256": "a1eef46c82f517fb97c542d9ad18d6302346bc3f06cb115f2556b48f93e1561f", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.3.4", + "scenario": "yes-local", + "fixture": "test/fixtures/unraid-webgui/7.3.4/yes-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/31c22f8327cca774dcbddd573dc76f70e87b2f10/etc/rc.d/rc.nginx", + "source_sha256": "eb6f1573606e208b70ac94367322a37e3bcba70fe03e53b6faa18c0ce3cb9d1c", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.3.4", + "scenario": "yes-sni", + "fixture": "test/fixtures/unraid-webgui/7.3.4/yes-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/31c22f8327cca774dcbddd573dc76f70e87b2f10/etc/rc.d/rc.nginx", + "source_sha256": "eb6f1573606e208b70ac94367322a37e3bcba70fe03e53b6faa18c0ce3cb9d1c", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.3.4", + "scenario": "auto-sni", + "fixture": "test/fixtures/unraid-webgui/7.3.4/auto-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/31c22f8327cca774dcbddd573dc76f70e87b2f10/etc/rc.d/rc.nginx", + "source_sha256": "eb6f1573606e208b70ac94367322a37e3bcba70fe03e53b6faa18c0ce3cb9d1c", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.3.4", + "scenario": "no-local", + "fixture": "test/fixtures/unraid-webgui/7.3.4/no-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/31c22f8327cca774dcbddd573dc76f70e87b2f10/etc/rc.d/rc.nginx", + "source_sha256": "eb6f1573606e208b70ac94367322a37e3bcba70fe03e53b6faa18c0ce3cb9d1c", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.3.4", + "scenario": "no-sni", + "fixture": "test/fixtures/unraid-webgui/7.3.4/no-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/31c22f8327cca774dcbddd573dc76f70e87b2f10/etc/rc.d/rc.nginx", + "source_sha256": "eb6f1573606e208b70ac94367322a37e3bcba70fe03e53b6faa18c0ce3cb9d1c", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.4.0-rc.2.5", + "scenario": "yes-local", + "fixture": "test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/b135287c706a30da44f71cc7820615209e83e9a0/etc/rc.d/rc.nginx", + "source_sha256": "a2bd4af2c86684501c1d2e54db686e01fcaf56806e40de31c5a01d23f59e9002", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.4.0-rc.2.5", + "scenario": "yes-sni", + "fixture": "test/fixtures/unraid-webgui/7.4.0-rc.2.5/yes-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/b135287c706a30da44f71cc7820615209e83e9a0/etc/rc.d/rc.nginx", + "source_sha256": "a2bd4af2c86684501c1d2e54db686e01fcaf56806e40de31c5a01d23f59e9002", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.4.0-rc.2.5", + "scenario": "auto-sni", + "fixture": "test/fixtures/unraid-webgui/7.4.0-rc.2.5/auto-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/b135287c706a30da44f71cc7820615209e83e9a0/etc/rc.d/rc.nginx", + "source_sha256": "a2bd4af2c86684501c1d2e54db686e01fcaf56806e40de31c5a01d23f59e9002", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.4.0-rc.2.5", + "scenario": "no-local", + "fixture": "test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-local.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/b135287c706a30da44f71cc7820615209e83e9a0/etc/rc.d/rc.nginx", + "source_sha256": "a2bd4af2c86684501c1d2e54db686e01fcaf56806e40de31c5a01d23f59e9002", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + }, + { + "version": "7.4.0-rc.2.5", + "scenario": "no-sni", + "fixture": "test/fixtures/unraid-webgui/7.4.0-rc.2.5/no-sni.conf", + "source_url": "https://raw.githubusercontent.com/unraid/webgui/b135287c706a30da44f71cc7820615209e83e9a0/etc/rc.d/rc.nginx", + "source_sha256": "a2bd4af2c86684501c1d2e54db686e01fcaf56806e40de31c5a01d23f59e9002", + "generation": "upstream build_servers with synthetic listen/redirect; not a live-host capture" + } +] diff --git a/test/unraid-fixtures.ts b/test/unraid-fixtures.ts new file mode 100644 index 0000000..b4a092a --- /dev/null +++ b/test/unraid-fixtures.ts @@ -0,0 +1,18 @@ +import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { tmpdir } from "node:os"; + +// Synthetic filesystem only; never redirect fixture generation at a NAS. +export function unraidRoot(version = "7.0.0", scenario = "yes-local", config?: string) { + const root = mkdtempSync(join(tmpdir(), "mua-unraid-layout-")); + for (const directory of ["etc/nginx/conf.d", "var/local/emhttp", "boot/config/ssl/certs"]) mkdirSync(join(root, directory), { recursive: true }); + writeFileSync(join(root, "etc/unraid-version"), `version="${version}"\n`); + writeFileSync(join(root, "var/local/emhttp/nginx.ini"), + `NGINX_USESSL="${scenario.split("-")[0]}"\nNGINX_LANMDNS="tower.local"\nNGINX_PORTSSL="443"\n`); + writeFileSync(join(root, "etc/nginx/nginx.conf"), "events {}\nhttp { include /etc/nginx/conf.d/servers.conf; }\n"); + writeFileSync(join(root, "etc/nginx/conf.d/servers.conf"), config ?? readFileSync(join(import.meta.dir, "fixtures/unraid-webgui", version, scenario + ".conf"), "utf8")); + for (const file of ["tower_unraid_bundle.pem", "certificate_bundle.pem", "unused-newest.pem"]) { + writeFileSync(join(root, "boot/config/ssl/certs", file), "synthetic fixture; certificate generated only by TLS integration tests\n"); + } + return root; +}