домены: реестр xlib.net.domains + синхронизация webDomain 3x-ui (T63, ADR-0012)
nixos flake checks / invariant-checks (push) Successful in 1m44s
test-runner / smoke (push) Successful in 1s

- lib/xlib/net.nix: domains.public/opencodes/internal/ad; все живые
  хостнеймы выводятся из реестра (nginx, coredns, authelia, nextcloud,
  gitea, vds, netbird, open-webui, opencode, nix-cache). Литералы — только
  в комментариях/example/email/trusted-key и в БД панели.
- 3xui-domain-sync.service: before+wantedBy podman-3xui_app, идемпотентно
  приводит settings.webDomain к host."3x-ui".certDomain ДО старта панели
  (R1.19/инвариант 19); контейнер сам не перезапускает.
- config-fingerprint до/после: значения не изменились — 0 отличий на
  rydiwo/atoridu/wsl, на sapphira/otreca только новый юнит и unitConfig.
- epral: убран nginx-mainline из strictModule (nix-on-droid не вычислялся
  с 5712abb); в AGENTS.md исправлен вывод (build.activationPackage) и
  добавлен --impure — T64 (проверить сборку на устройстве).
- .agent: закрыты T10/T49/T50/T54, добавлены T63 (done) и T64 (pending),
  ADR-0012; phases в manifest.json синхронизированы с checkpoints.json.
This commit is contained in:
oqyude committed 2026-11-26 20:16:09 +03:00
1 parent d2692b752b
commit ae760f6ab4
28 files changed
+538 -133

No files matched your search

+74
View File
@@ -22,6 +22,25 @@ let
row = con.execute("select value from settings where key = ?", (sys.argv[2],)).fetchone()
sys.stdout.write((row[0] if row and row[0] else "") + "\n")
'';
# Записывает значение одной настройки в таблицу `settings` (открывает БД
# на запись). Используется только `domainSync`, который запускается ДО
# контейнера панели — конкурентного доступа к SQLite в этот момент нет.
writeSettingPy = ''
import sqlite3, sys
con = sqlite3.connect(sys.argv[1], timeout=10)
con.execute("PRAGMA busy_timeout = 10000")
cur = con.execute(
"update settings set value = ? where key = ?",
(sys.argv[3], sys.argv[2]),
)
if cur.rowcount == 0:
con.execute(
"insert into settings(key, value) values(?, ?)",
(sys.argv[2], sys.argv[3]),
)
con.commit()
con.close()
'';
in
{
options.modules."3x-ui" = {
@@ -185,5 +204,60 @@ in
};
defaultText = lib.literalExpression "writeShellApplication { name = \"reconfig-runner\"; }";
};
domainSync = lib.mkOption {
type = lib.types.package;
description = ''
Скрипт `3xui-domain-sync`: приводит `webDomain` в таблице `settings`
БД панели 3x-ui к домену, объявленному в Nix. Панель читает
`webDomain` при старте и отвечает только на него (403 на чужой Host —
R1.20/инвариант 19), поэтому юнит `3xui-domain-sync` запускается
ДО контейнера (`before` + `wantedBy = podman-3xui_app.service`, см.
modules/containers/3x-ui.nix). Идемпотентен: при совпадении ничего
не пишет. Если БД ещё нет (первый запуск) — выходит без ошибки.
'';
default = pkgs.writeShellApplication {
name = "3xui-domain-sync";
runtimeInputs = [ pkgs.python3 ];
text = ''
#!/usr/bin/env bash
# Сверка persisted-домена панели 3x-ui с Nix.
#
# Зачем: `webDomain` живёт в БД панели, а не в Nix (инвариант 19).
# При миграции на другой домен `nixos-rebuild` обновляет nginx и
# сертификаты, но панель продолжает отвечать на старое имя и
# отдаёт 403 на новый Host. Этот юнит выполняется до старта
# контейнера и правит БД, пока панель ещё не запущена.
#
# Миграция: nixos-rebuild switch → systemctl restart podman-3xui_app.
# (Юнит не перезапускает контейнер сам: иначе получился бы цикл
# зависимостей.)
set -euo pipefail
: "''${PANEL_DB:?PANEL_DB is required (host path to x-ui.db)}"
: "''${PANEL_DOMAIN:?PANEL_DOMAIN is required (webDomain declared in Nix)}"
log() { printf '[domain-sync] %s\n' "$*" >&2; }
if [ ! -f "$PANEL_DB" ]; then
log "database not found at '$PANEL_DB' — nothing to reconcile (first boot?)"
exit 0
fi
DB_URI="file:''${PANEL_DB}?mode=ro"
CURRENT="$(python3 -c '${readSettingPy}' "$DB_URI" webDomain)"
if [ "$CURRENT" = "$PANEL_DOMAIN" ]; then
log "webDomain is already '$PANEL_DOMAIN' — no change"
exit 0
fi
log "webDomain '$CURRENT' -> '$PANEL_DOMAIN'"
python3 -c '${writeSettingPy}' "$PANEL_DB" webDomain "$PANEL_DOMAIN"
log "database updated; the panel reads webDomain when the container starts"
'';
};
defaultText = lib.literalExpression "writeShellApplication { name = \"3xui-domain-sync\"; }";
};
};
}
+28
View File
@@ -123,6 +123,34 @@ in
partOf = [ "podman-compose-3x-ui-root.target" ];
wantedBy = [ "podman-compose-3x-ui-root.target" ];
};
# `webDomain` — persisted-настройка панели (таблица `settings` в
# x-ui.db), а не значение из Nix (инвариант 19 / R1.20). При смене
# домена rebuild обновит nginx и ACME, но панель продолжит отвечать
# на старое имя → 403 на каждом запросе. Юнит выполняется ДО старта
# контейнера (пока SQLite никто не держит) и правит БД; панель
# читает настройку при старте.
#
# Триггер осознанно не автоматический: юнит стартует вместе с
# `podman-3xui_app.service`, поэтому миграция =
# nixos-rebuild switch && systemctl restart podman-3xui_app
# (перезапуск из самого юнита дал бы цикл зависимостей).
# На `vds` guard пуст (mkStorageGuard), на sapphira — монтирование
# External, как у самого контейнера.
"3xui-domain-sync" = lib.mkIf (certDomain != null) {
description = "Reconcile the 3x-ui panel webDomain with the domain declared in Nix";
unitConfig = xlib.helpers.mkStorageGuard xlib;
before = [ "podman-3xui_app.service" ];
wantedBy = [ "podman-3xui_app.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = false;
ExecStart = "${config.modules."3x-ui".domainSync}/bin/3xui-domain-sync";
Environment = [
"PANEL_DB=${panel}/db/x-ui.db"
"PANEL_DOMAIN=${certDomain}"
];
};
};
# Auto-update was removed intentionally: the `podman pull` path on the
# auto-update timer caused the declarative Nix state to diverge from the
# runtime state in 2026-10-04 (see
+3 -2
View File
@@ -36,6 +36,7 @@
# All of the above are wired into modules/server/nginx.nix:open.zeroq.su.
let
panel = "${xlib.dirs.services-nodes-folder}/${xlib.device.hostname}/open-webui";
fqdn = name: "${name}.${xlib.net.domains.public}";
in
{
virtualisation = {
@@ -57,11 +58,11 @@ in
PORT = "8080";
# Required when behind a public HTTPS URL — OAuth callbacks,
# share links and internal redirects resolve against this.
WEBUI_URL = "https://open.zeroq.su";
WEBUI_URL = "https://${fqdn "open"}";
# Must exactly match WEBUI_URL or WebSocket connections fail
# silently (per upstream HTTPS docs). nginx (127.0.0.1) is the
# only allowed origin, so a single explicit URL is enough.
CORS_ALLOW_ORIGIN = "https://open.zeroq.su";
CORS_ALLOW_ORIGIN = "https://${fqdn "open"}";
# Honour X-Forwarded-* headers from the reverse proxy.
FORWARDED_ALLOW_IPS = "127.0.0.1";
# Closed self-hosted: admin creates accounts manually after the
-1
View File
@@ -48,7 +48,6 @@ let
# ./essentials
# ./users.nix
./options.nix
./nginx-mainline.nix
(./. + "/${xlib.device.type}")
# sops-nix.nixosModules.sops
];
+2 -1
View File
@@ -2,6 +2,7 @@
config,
lib,
pkgs,
xlib,
...
}:
{
@@ -15,7 +16,7 @@
settings = {
require-sigs = false;
substituters = [
"https://nix-cache.zeroq.su"
"https://nix-cache.${xlib.net.domains.public}"
"https://cache.nixos.org"
"https://nix-community.cachix.org"
"https://mirror.yandex.ru/nixos"
+4 -3
View File
@@ -9,9 +9,10 @@
# (`nixpkgs-master` в flake) уже 1.31.9 — берём пакет оттуда, пока фикс не
# доедет до unstable.
#
# Модуль общий: его импортируют и `defaultModule`, и `strictModule`, поэтому
# правило действует на всех NixOS-хостах (sapphira, rydiwo, vds), а не только
# на том, где nginx терминирует публичный TLS.
# Модуль импортирует `defaultModule` (NixOS-хосты: sapphira, rydiwo, vds).
# В `strictModule` его НЕТ: strict используется nix-on-droid (`configurations/
# mobile.nix`), где нет ни `services.nginx`, ни аргумента `inputs` — импорт
# ронял `nixOnDroidConfigurations.epral` (найдено 2026-11-26).
{ pkgs, inputs, ... }:
{
services.nginx.package =
+1 -1
View File
@@ -56,7 +56,7 @@ in
'';
cookieDomain = lib.mkOption {
type = lib.types.str;
default = "zeroq.su";
default = xlib.net.domains.public;
description = ''
Domain scope for Authelia session cookies and the login-UI vhost
(`authelia.<cookieDomain>`). All protected vhosts must be subdomains
+44 -39
View File
@@ -10,56 +10,61 @@
# Every address here comes from the fleet registry (lib/xlib/net.nix): the
# zone and the nginx vhosts have to agree, and a DHCP lease that moved must
# not leave half of the zone pointing at the old machine.
let
# Zone names and records come from the fleet registry (lib/xlib/net.nix).
fqdn = name: "${name}.${xlib.net.domains.public}";
lan = name: "${name}.${xlib.net.domains.internal}";
in
{
services.coredns = {
enable = true;
config = ''
zeroq.su:53 {
${xlib.net.domains.public}:53 {
hosts {
${xlib.net.hosts.otreca.public} x.zeroq.su
${xlib.net.hosts.sapphira.lan} authelia.zeroq.su
${xlib.net.hosts.sapphira.lan} calibre.zeroq.su
${xlib.net.hosts.sapphira.lan} dns.zeroq.su
${xlib.net.hosts.sapphira.lan} flux.zeroq.su
${xlib.net.hosts.sapphira.lan} git.zeroq.su
${xlib.net.hosts.sapphira.lan} glances.zeroq.su
${xlib.net.hosts.sapphira.lan} herdr.zeroq.su
${xlib.net.hosts.sapphira.lan} homebox.zeroq.su
${xlib.net.hosts.sapphira.lan} immich.zeroq.su
${xlib.net.hosts.sapphira.lan} kuma.zeroq.su
${xlib.net.hosts.sapphira.lan} navidrome.zeroq.su
${xlib.net.hosts.sapphira.lan} nextcloud.zeroq.su
${xlib.net.hosts.sapphira.lan} open.zeroq.su
${xlib.net.hosts.sapphira.lan} office.zeroq.su
${xlib.net.hosts.sapphira.lan} pdf.zeroq.su
${xlib.net.hosts.sapphira.lan} syncthing.zeroq.su
${xlib.net.hosts.sapphira.lan} talk.zeroq.su
${xlib.net.hosts.sapphira.lan} turn.zeroq.su
${xlib.net.hosts.sapphira.lan} vtimeline.zeroq.su
${xlib.net.hosts.otreca.public} ${fqdn "x"}
${xlib.net.hosts.sapphira.lan} ${fqdn "authelia"}
${xlib.net.hosts.sapphira.lan} ${fqdn "calibre"}
${xlib.net.hosts.sapphira.lan} ${fqdn "dns"}
${xlib.net.hosts.sapphira.lan} ${fqdn "flux"}
${xlib.net.hosts.sapphira.lan} ${fqdn "git"}
${xlib.net.hosts.sapphira.lan} ${fqdn "glances"}
${xlib.net.hosts.sapphira.lan} ${fqdn "herdr"}
${xlib.net.hosts.sapphira.lan} ${fqdn "homebox"}
${xlib.net.hosts.sapphira.lan} ${fqdn "immich"}
${xlib.net.hosts.sapphira.lan} ${fqdn "kuma"}
${xlib.net.hosts.sapphira.lan} ${fqdn "navidrome"}
${xlib.net.hosts.sapphira.lan} ${fqdn "nextcloud"}
${xlib.net.hosts.sapphira.lan} ${fqdn "open"}
${xlib.net.hosts.sapphira.lan} ${fqdn "office"}
${xlib.net.hosts.sapphira.lan} ${fqdn "pdf"}
${xlib.net.hosts.sapphira.lan} ${fqdn "syncthing"}
${xlib.net.hosts.sapphira.lan} ${fqdn "talk"}
${xlib.net.hosts.sapphira.lan} ${fqdn "turn"}
${xlib.net.hosts.sapphira.lan} ${fqdn "vtimeline"}
fallthrough
}
cache 300
log
}
home.arpa:53 {
${xlib.net.domains.internal}:53 {
hosts {
${xlib.net.hosts.vetymae.lan} vetymae.home.arpa
${xlib.net.hosts.sapphira.lan} ca.home.arpa
${xlib.net.hosts.sapphira.lan} calibre.home.arpa
${xlib.net.hosts.sapphira.lan} dns.home.arpa
${xlib.net.hosts.sapphira.lan} flux.home.arpa
${xlib.net.hosts.sapphira.lan} git.home.arpa
${xlib.net.hosts.sapphira.lan} glances.home.arpa
${xlib.net.hosts.sapphira.lan} home.arpa
${xlib.net.hosts.sapphira.lan} homebox.home.arpa
${xlib.net.hosts.sapphira.lan} immich.home.arpa
${xlib.net.hosts.sapphira.lan} kuma.home.arpa
${xlib.net.hosts.sapphira.lan} navidrome.home.arpa
${xlib.net.hosts.sapphira.lan} nextcloud.home.arpa
${xlib.net.hosts.sapphira.lan} office.home.arpa
${xlib.net.hosts.sapphira.lan} pdf.home.arpa
${xlib.net.hosts.sapphira.lan} sapphira.home.arpa
${xlib.net.hosts.sapphira.lan} syncthing.home.arpa
${xlib.net.hosts.vetymae.lan} ${lan "vetymae"}
${xlib.net.hosts.sapphira.lan} ${lan "ca"}
${xlib.net.hosts.sapphira.lan} ${lan "calibre"}
${xlib.net.hosts.sapphira.lan} ${lan "dns"}
${xlib.net.hosts.sapphira.lan} ${lan "flux"}
${xlib.net.hosts.sapphira.lan} ${lan "git"}
${xlib.net.hosts.sapphira.lan} ${lan "glances"}
${xlib.net.hosts.sapphira.lan} ${xlib.net.domains.internal}
${xlib.net.hosts.sapphira.lan} ${lan "homebox"}
${xlib.net.hosts.sapphira.lan} ${lan "immich"}
${xlib.net.hosts.sapphira.lan} ${lan "kuma"}
${xlib.net.hosts.sapphira.lan} ${lan "navidrome"}
${xlib.net.hosts.sapphira.lan} ${lan "nextcloud"}
${xlib.net.hosts.sapphira.lan} ${lan "office"}
${xlib.net.hosts.sapphira.lan} ${lan "pdf"}
${xlib.net.hosts.sapphira.lan} ${lan "sapphira"}
${xlib.net.hosts.sapphira.lan} ${lan "syncthing"}
fallthrough
}
cache 300
+3 -3
View File
@@ -67,13 +67,13 @@
# there are other vhosts on the same port). Cert is still mounted in
# case 3x-ui is later reconfigured to terminate TLS itself (e.g. for
# direct node-API access); nginx doesn't have to use it.
host."3x-ui".certDomain = "x.zeroq.su";
host."3x-ui".certDomain = "x.${xlib.net.domains.public}";
# Authelia SSO — currently protects vtimeline.zeroq.su (replaces the
# previous nginx auth_basic htpasswd). Cookie domain is .zeroq.su so a
# single Authelia session covers every protected vhost under the zone.
host.authelia = {
enable = true;
cookieDomain = "zeroq.su";
cookieDomain = xlib.net.domains.public;
};
# ──────────────────────────────────────────────────────────────────────
@@ -141,7 +141,7 @@
Type = "oneshot";
ExecStart = lib.getExe config.modules."3x-ui".reconfigRunner;
Environment = [
"PANEL_URL=https://x.zeroq.su"
"PANEL_URL=https://x.${xlib.net.domains.public}"
];
};
};
+4 -3
View File
@@ -29,6 +29,7 @@
# • Authelia wildcard уже покрывает — менять ничего не надо
let
cfg = config.host.engipy-frontend;
fqdn = name: "${name}.${xlib.net.domains.public}";
in
{
options.host.engipy-frontend = {
@@ -39,7 +40,7 @@ in
domain = lib.mkOption {
type = lib.types.str;
default = "engipy.zeroq.su";
default = fqdn "engipy";
description = "Домен для vhost.";
};
@@ -93,7 +94,7 @@ in
extraConfig = ''
auth_request /authelia;
auth_request_set $authelia_user $upstream_http_remote_user;
error_page 401 =302 https://authelia.zeroq.su/?rd=$scheme://$host$request_uri;
error_page 401 =302 https://${fqdn "authelia"}/?rd=$scheme://$host$request_uri;
client_max_body_size 50m;
proxy_read_timeout 120s;
proxy_send_timeout 120s;
@@ -109,7 +110,7 @@ in
extraConfig = ''
auth_request /authelia;
auth_request_set $authelia_user $upstream_http_remote_user;
error_page 401 =302 https://authelia.zeroq.su/?rd=$scheme://$host$request_uri;
error_page 401 =302 https://${fqdn "authelia"}/?rd=$scheme://$host$request_uri;
'';
};
# Forward-auth endpoint для /authelia sub-request.
+2 -1
View File
@@ -13,6 +13,7 @@ let
# escaped form is spelled out literally: a literal backslash before x2d.
# The `assertions` entry below fails the build if this ever drifts.
unitKey = "gitea-runner-ci\\x2dsapphira";
fqdn = name: "${name}.${xlib.net.domains.public}";
in
{
# ----- Static user for the runner ----------------------------------------
@@ -51,7 +52,7 @@ in
services.gitea-actions-runner.instances."${name}" = {
enable = true;
name = name;
url = "https://git.zeroq.su/"; # matches modules/server/gitea.nix ROOT_URL
url = "https://${fqdn "git"}/"; # matches modules/server/gitea.nix ROOT_URL
tokenFile = config.sops.secrets.gitea-runner-registration.path;
labels = [ "native:host" ]; # only host-executor; no docker required
+1 -1
View File
@@ -17,7 +17,7 @@
# nixpkgs-unstable removed `DOMAIN` — must use the full public URL
# in `ROOT_URL` instead. External entry is HTTPS via nginx with
# ACME (modules/server/nginx.nix:53), so scheme is https, no port.
ROOT_URL = "https://git.zeroq.su/";
ROOT_URL = "https://git.${xlib.net.domains.public}/";
HTTP_PORT = 3000;
};
service.DISABLE_REGISTRATION = true;
+11 -9
View File
@@ -12,13 +12,15 @@ let
config.allowUnfree = true;
config.allowUnfreePredicate = true;
};
fqdn = name: "${name}.${xlib.net.domains.public}";
lan = name: "${name}.${xlib.net.domains.internal}";
in
{
services = {
nextcloud-whiteboard-server = {
enable = true;
settings = {
NEXTCLOUD_URL = "https://nextcloud.zeroq.su";
NEXTCLOUD_URL = "https://${fqdn "nextcloud"}";
};
secrets = [ config.sops.secrets.nextcloud-whiteboard-jwt.path ];
};
@@ -27,7 +29,7 @@ in
hostName = "talk.private";
backends.nextcloud = {
urls = [
"https://nextcloud.zeroq.su"
"https://${fqdn "nextcloud"}"
# "https://nextcloud.home.arpa"
];
secretFile = config.sops.secrets.nextcloud-talk-secret.path;
@@ -47,8 +49,8 @@ in
secretFile = config.sops.secrets.turn-secret.path;
apikeyFile = config.sops.secrets.turn-api-key.path;
servers = [
"turn:turn.zeroq.su:3478?transport=udp"
"turn:turn.zeroq.su:3478?transport=tcp"
"turn:${fqdn "turn"}:3478?transport=udp"
"turn:${fqdn "turn"}:3478?transport=tcp"
# "turns:turn.zeroq.su:5349?transport=tcp"
];
};
@@ -82,11 +84,11 @@ in
xlib.net.hosts.sapphira.lan
xlib.net.hosts.router.public
"localhost"
"nextcloud.home.arpa"
(lan "nextcloud")
"nextcloud.private"
"nextcloud.zeroq.su"
"office.home.arpa"
"office.zeroq.su"
(fqdn "nextcloud")
(lan "office")
(fqdn "office")
];
trusted_proxies = [
xlib.net.hosts.otreca.tailscale
@@ -101,7 +103,7 @@ in
notify_push = {
enable = true;
bendDomainToLocalhost = true;
nextcloudUrl = "https://nextcloud.zeroq.su";
nextcloudUrl = "https://${fqdn "nextcloud"}";
};
# phpPackage = pkgs.php85;
extraApps = {
+32 -27
View File
@@ -14,6 +14,11 @@ let
# server, from the fleet registry (lib/xlib/net.nix).
server = xlib.net.hosts.sapphira.lan;
# DNS names come from the fleet registry (lib/xlib/net.nix): a move to
# another registrable domain changes `domains.public` there, not this file.
fqdn = name: "${name}.${xlib.net.domains.public}";
opencodes = name: "${name}.${xlib.net.domains.opencodes}";
mkProxy =
{
domain,
@@ -39,7 +44,7 @@ let
sites = [
{
domain = "immich.zeroq.su";
domain = fqdn "immich";
port = 2283;
addSSL = true;
extraConfig = bigUploads;
@@ -60,19 +65,19 @@ let
# port = 19999;
# }
{
domain = "git.zeroq.su";
domain = fqdn "git";
port = 3000;
}
{
domain = "homebox.zeroq.su";
domain = fqdn "homebox";
port = 7745;
}
{
domain = "flux.zeroq.su";
domain = fqdn "flux";
port = 6061;
}
{
domain = "tape-rotation.zeroq.su";
domain = fqdn "tape-rotation";
port = 5174;
}
# NOTE: open.zeroq.su is intentionally NOT in this `sites` list —
@@ -82,22 +87,22 @@ let
# to `virtualHosts` below, alongside x.zeroq.su (3x-ui panel,
# same loopback-only pattern).
{
domain = "navidrome.zeroq.su";
domain = fqdn "navidrome";
port = 4533;
addSSL = true;
}
{
domain = "calibre.zeroq.su";
domain = fqdn "calibre";
port = 8083;
extraConfig = bigUploads;
}
{
domain = "nix-cache.zeroq.su";
domain = fqdn "nix-cache";
port = 5000;
extraConfig = bigUploads;
}
{
domain = "pdf.zeroq.su";
domain = fqdn "pdf";
port = 8446;
extraConfig = bigUploads;
}
@@ -131,7 +136,7 @@ in
}
];
};
"office.zeroq.su" = {
"${fqdn "office"}" = {
forceSSL = true;
enableACME = true;
};
@@ -146,7 +151,7 @@ in
# client_max_body_size 6m matches the server.js body limit
# (5 MB hard cap). nginx's default 1m would 413 any upload near
# the cap before the request reached the node process.
"vtimeline.zeroq.su" = {
"${fqdn "vtimeline"}" = {
forceSSL = true;
enableACME = true;
locations = {
@@ -172,7 +177,7 @@ in
# login. Pass the full origin (scheme + host + path) so
# Authelia constructs an absolute redirect back to the
# original vhost.
error_page 401 =302 https://authelia.zeroq.su/?rd=$scheme://$host$request_uri;
error_page 401 =302 https://${fqdn "authelia"}/?rd=$scheme://$host$request_uri;
client_max_body_size 6m;
'';
};
@@ -218,7 +223,7 @@ in
# vtimeline.zeroq.su above — the wildcard rule `*.zeroq.su` in
# modules/server/authelia.nix already covers this subdomain under
# `one_factor`, so no policy change is needed.
"tty.zeroq.su" = {
"${fqdn "tty"}" = {
forceSSL = true;
enableACME = true;
locations = {
@@ -235,7 +240,7 @@ in
# `$scheme://$host$request_uri` so the post-login `rd`
# lands the user back on tty.zeroq.su, not on
# authelia.zeroq.su/<path>.
error_page 401 =302 https://authelia.zeroq.su/?rd=$scheme://$host$request_uri;
error_page 401 =302 https://${fqdn "authelia"}/?rd=$scheme://$host$request_uri;
'';
};
"= /authelia" = {
@@ -291,7 +296,7 @@ in
#
# proxyWebsockets обязателен: терминал стримится по WS
# (/ws/session/<name>), без апгрейда вкладка не получит ни байта.
"vetymae.webmux.zeroq.su" = {
"${fqdn "vetymae.webmux"}" = {
forceSSL = true;
enableACME = true;
locations = {
@@ -306,7 +311,7 @@ in
# запросе отдаёт 302 + Location → nginx показал бы 500 «auth
# request unexpected status». Редирект ведёт на логин с
# абсолютным rd, чтобы после входа вернуться именно сюда.
error_page 401 =302 https://authelia.zeroq.su/?rd=$scheme://$host$request_uri;
error_page 401 =302 https://${fqdn "authelia"}/?rd=$scheme://$host$request_uri;
# Долгоживущие WS-соединения терминала: дефолтные 60 с
# read/send-timeout рвут простаивающую вкладку.
proxy_read_timeout 3600s;
@@ -379,7 +384,7 @@ in
# patch that reads X-Forwarded-Host (fork + plugin link) — the
# same-origin check assumes direct loopback or Tailscale serve,
# both of which give request.url a host that matches the browser.
"herdr.zeroq.su" = {
"${fqdn "herdr"}" = {
forceSSL = true;
enableACME = true;
locations = {
@@ -433,7 +438,7 @@ in
# Authelia has a stable absolute URL to redirect users to. Authelia
# generates internal links against $session.cookies[0].authelia_url,
# which is set to https://${autheliaFqdn}/ in modules/server/authelia.nix.
"authelia.zeroq.su" = {
"${fqdn "authelia"}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
@@ -464,7 +469,7 @@ in
];
extraConfig = bigUploads;
};
"x.zeroq.su" = {
"${fqdn "x"}" = {
forceSSL = true;
enableACME = true;
locations = {
@@ -508,7 +513,7 @@ in
# proxy_read_timeout 300s;
# '';
# };
"zeroq.su" = {
"${xlib.net.domains.public}" = {
forceSSL = true;
enableACME = true;
root = pkgs.writeTextDir "index.html" ''
@@ -537,7 +542,7 @@ in
# и по 22, и по 4096). Рестарт службы Tailscale не помогает, нужен
# интерактивный `tailscale up` на самом хосте. Вернуться на tailnet
# стоит только после этого.
"vetymae.opencodes.zeroq.su" = {
"${opencodes "vetymae"}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
@@ -545,7 +550,7 @@ in
proxyWebsockets = true;
};
};
"lamet.opencodes.zeroq.su" = {
"${opencodes "lamet"}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
@@ -572,7 +577,7 @@ in
# этой же машины. CORS применяется только к cross-origin запросам;
# веб-UI, отданный через этот же nginx-vhost, идёт same-origin,
# поэтому расхождение имён на работу не влияет.
"etherea.opencodes.zeroq.su" = {
"${opencodes "etherea"}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
@@ -587,7 +592,7 @@ in
# что хост недоступен. Vhost поднимается вместе с etherea, и
# отдаёт 502, пока dejavu не поднимут и не запустят на нём
# opencode на 4096. Это ожидаемо, а не поломка конфига.
"dejavu.opencodes.zeroq.su" = {
"${opencodes "dejavu"}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
@@ -608,7 +613,7 @@ in
#
# DNS: *.opencodes.zeroq.su — wildcard CNAME на home.zeroq.su
# (37.128.246.126), отдельная запись в zone не нужна.
"rydiwo.opencodes.zeroq.su" = {
"${opencodes "rydiwo"}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
@@ -619,7 +624,7 @@ in
# sapphira itself: opencode web runs as a systemd user service
# (programs.opencode.web.enable in home/modules/opencode.nix) on
# 127.0.0.1:4096 with --hostname 0.0.0.0.
"opencode.zeroq.su" = {
"${fqdn "opencode"}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
@@ -627,7 +632,7 @@ in
proxyWebsockets = true;
};
};
"nextcloud.zeroq.su" = {
"${fqdn "nextcloud"}" = {
forceSSL = true;
enableACME = true;
locations = {
+1 -1
View File
@@ -17,7 +17,7 @@
services.onlyoffice = {
enable = true;
# package = previous.onlyoffice-documentserver;
hostname = "office.zeroq.su";
hostname = "office.${xlib.net.domains.public}";
port = 8090;
allowLocalConnections = true;
wopi = true;
+2 -2
View File
@@ -24,7 +24,7 @@
# mapping is published. (Restored 2026-10-10 after
# T10/C5 wrongly removed it and broke Xray REALITY.)
host."3x-ui" = {
certDomain = "pubray1.zeroq.su";
certDomain = "pubray1.${xlib.net.domains.public}";
reality443Forwarding = true;
};
@@ -86,7 +86,7 @@
Type = "oneshot";
ExecStart = lib.getExe config.modules."3x-ui".reconfigRunner;
Environment = [
"PANEL_URL=https://pubray1.zeroq.su"
"PANEL_URL=https://pubray1.${xlib.net.domains.public}"
];
};
};
+4 -3
View File
@@ -1,23 +1,24 @@
{
config,
pkgs,
xlib,
...
}:
{
services.netbird.server = {
enable = false;
enableNginx = true;
domain = "netbird.zeroq.su";
domain = "netbird.${xlib.net.domains.public}";
dashboard = {
enable = false;
domain = "netbird.zeroq.su";
domain = "netbird.${xlib.net.domains.public}";
settings = {
#AUTH_AUTHORITY = "nbp_ufe0v5mbb5H1lQWL8eJfuzJ5ItPmlM46Mik0";
};
};
management = {
enable = false;
domain = "netbird.zeroq.su";
domain = "netbird.${xlib.net.domains.public}";
};
};
+6 -2
View File
@@ -2,6 +2,7 @@
config,
inputs,
pkgs,
xlib,
...
}:
# VDS nginx differs from server's in one key way: port 443 is owned
@@ -24,6 +25,9 @@
# the TLS stream as-is, so Xray sees a real port-443 connection even
# though podman DNATs it via host:15380.
let
# Public name of the VDS host: the 3x-ui panel vhost and its SNI branch.
fqdn = name: "${name}.${xlib.net.domains.public}";
# Goes inside the auto-generated `stream {}` block (services.nginx.streamConfig).
# pubray1.zeroq.su → 3x-ui panel; everything else (including any SNI
# a REALITY client uses, e.g. media.mediavitrina.ru) → Xray.
@@ -32,7 +36,7 @@ let
map $ssl_preread_server_name $sni_backend {
default xray;
pubray1.zeroq.su panel;
${fqdn "pubray1"} panel;
}
upstream panel {
@@ -62,7 +66,7 @@ in
# ACME only — 443 is owned by the stream block, not by http { server {} }.
# Don't add forceSSL: it would generate an HTTPS server block that
# conflicts with the stream listener.
virtualHosts."pubray1.zeroq.su".enableACME = true;
virtualHosts."${fqdn "pubray1"}".enableACME = true;
# Lands inside the auto-generated `stream {}` block.
streamConfig = streamConfig;
};