nix-config/hosts/heather/caddy.nix
mikl 55cd7158a5 heather: fully remove jitsi (clean slate for fresh install)
Removed jitsi from arion-compose.nix, caddy.nix, default.nix.
Wiped on heather: containers, volumes, images, secrets, LE cert.
Removed YC SG rule 10000/udp. Will reinstall from scratch following docs only.
2026-07-13 00:28:59 +03:00

87 lines
3.1 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# heather — Caddy как единый edge (TLS termination, reverse proxy).
#
# Заменяет Traefik (k3s built-in, отключён) и старые Caddy на iscg-dev/jul11.
# Паттерн как на iscg-dev: system Caddy, конфиг декларативно в nix.
#
# Caddy терминирует TLS на :80/:443 и роутит по Host на:
# - host-сервисы (syncthing GUI на localhost:8384) — напрямую
# - docker-контейнеры (forgejo на localhost:3030 и т.д.) — проброшенные порты
#
# ACME: пока staging (чтобы не забанили Let's Encrypt пока DNS не переведён на
# heather). Когда A-записи iscg.dev → 51.250.45.111 — переключим на production
# (убрать acme_ca, Caddy использует production LE по умолчанию).
{ config, pkgs, lib, ... }:
let
# caddy/basic-auth под паролем. hash сгенерить:
# caddy hash-password --plaintext '<password>'
# (на heather: nix-shell -p caddy --run 'caddy hash-password ...')
# Защищает syncthing GUI снаружи (GUI слушает только 127.0.0.1:8384,
# Caddy проксирует sync.iscg.dev + basicauth).
syncBasicAuth = ''
basicauth {
mikl $2a$14$ozHN9/aa4VhPX43NN8MKdODKvOoJ5MBpOUFhzkxwvb58ZI5b6eqEK
}
'';
in {
services.caddy = {
enable = true;
# DNS переведён на heather (2026-07-12). Production ACME.
# Если нужен staging обратно: раскомментировать acmeCA ниже.
# acmeCA = "https://acme-staging-v02.api.letsencrypt.org/directory";
email = "mikl@iscg.dev";
virtualHosts = {
# --- Syncthing GUI (host-сервис) ---
# header_up Host 127.0.0.1:8384 — обходим syncthing host-check (DNS
# rebinding protection): syncthing сравнивает Host header с адресом
# прослушивания (127.0.0.1:8384) и отдаёт 403 "Host check error" для
# внешних доменов. Подменяем Host на бэкенде.
"sync.iscg.dev".extraConfig = syncBasicAuth + ''
reverse_proxy 127.0.0.1:8384 {
header_up Host 127.0.0.1:8384
}
'';
# --- Контейнеры (arion, см. arion-compose.nix) ---
# Forgejo
"git.iscg.dev".extraConfig = ''
reverse_proxy 127.0.0.1:3030
'';
# Matrix tuwunel (homeserver)
"iscg.dev".extraConfig = ''
reverse_proxy 127.0.0.1:8008
encode zstd gzip
'';
# Matrix federation
"iscg.dev:8448".extraConfig = ''
reverse_proxy 127.0.0.1:8008
'';
# tuwunel-admin
"admin.iscg.dev".extraConfig = ''
reverse_proxy 127.0.0.1:8009
'';
# Cinny (matrix web client)
"chat.iscg.dev".extraConfig = ''
reverse_proxy 127.0.0.1:8080
encode zstd gzip
'';
# Teable
"teable.iscg.dev".extraConfig = ''
reverse_proxy 127.0.0.1:2345
'';
# Silverbullet
"note.iscg.dev".extraConfig = ''
reverse_proxy 127.0.0.1:3001
'';
};
};
}