From 862ca9bae84f0e4b4cd99c9ebe38ddfb71f8f9af Mon Sep 17 00:00:00 2001 From: kaffa Date: Wed, 8 Apr 2026 14:27:03 +0900 Subject: [PATCH] =?UTF-8?q?sandbox-tokyo:=20Debian=20=E2=86=92=20NixOS=202?= =?UTF-8?q?5.05=20=EC=A0=84=ED=99=98=20(Linode=20zlambda)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 새 노트 infra/sandbox-tokyo-nixos.md 작성 (설치 과정, configuration, 후속 작업) - infra-hosts: 호스트 항목 NixOS 베이스로 갱신, Tailscale IP 100.79.87.48 → 100.78.51.18, vault-prod/wg-easy 항목 제거 - netbis: NixOS 전환으로 APISIX/etcd 컨테이너 모두 제거된 상태 표기, DR 미가동 - searxng: tlsproxy/microsocks 중단, 새 IP 반영 - vault: SSH CA에서 sandbox-tokyo 재등록 필요 표기 - postgresql-ha: /apisix/tokyo prefix 미사용 표기 --- infra/infra-hosts.md | 6 +- infra/postgresql-ha.md | 4 +- infra/sandbox-tokyo-nixos.md | 109 +++++++++++++++++++++++++++++++++++ infra/vault.md | 2 +- services/netbis.md | 27 ++++++--- services/searxng.md | 6 +- 6 files changed, 135 insertions(+), 19 deletions(-) create mode 100644 infra/sandbox-tokyo-nixos.md diff --git a/infra/infra-hosts.md b/infra/infra-hosts.md index ad1af8a..f04bd61 100644 --- a/infra/infra-hosts.md +++ b/infra/infra-hosts.md @@ -1,6 +1,6 @@ --- title: 인프라 호스트 및 네트워크 -updated: 2026-04-08 2.5G LAN 4노드 완성 +updated: 2026-04-08 sandbox-tokyo NixOS 전환 tags: [infra, network, kr-zone, openwrt] --- @@ -18,7 +18,7 @@ tags: [infra, network, kr-zone, openwrt] | incus-kr2 | 100.119.109.41 | Incus+K3s 호스트 (서울) | K3s control-plane (LAN 192.168.9.135), default, inbest 프로젝트 | | incus-hp2 | 100.100.52.34 | Incus+K3s 호스트 (서울) | Xeon E5-2670 32코어, 188GB RAM, K3s worker/k3s-agent (LAN 192.168.9.134), default, inbest 프로젝트 | | openwrt-gw | 100.66.60.66 | OpenWrt 라우터 (서울) | HAProxy: 80/443 → MetalLB Traefik(192.168.9.53:80/443), 9080/9443 → MetalLB APISIX(192.168.9.50:80/443) | -| sandbox-tokyo | 100.79.87.48 | [[netbis]] 예비 APISIX Gateway (도쿄, Linode) | APISIX 3.15.0 + etcd, 공인 139.162.71.52, netbis 도메인 DR용 | +| sandbox-tokyo | 100.78.51.18 | NixOS 베이스 호스트 (도쿄, Linode "zlambda") | NixOS 25.05 (Warbler), 공인 139.162.71.52, sshd+tailscale+docker, 2026-04-08 Debian→NixOS 전환 (이전 APISIX/etcd/microsocks/tlsproxy/vault-prod/wg-easy 모두 제거됨), Linode 프로필 kernel=`linode/direct-disk`, configuration: Mac `~/nixos-zlambda/` flake | | relay4wd (sandbox-kr2) | 100.103.161.4 | APISIX Gateway (서울, AWS Lightsail) | 공인 52.79.45.166, inbest 포트포워딩, Docker APISIX 3.15.0, Debian 12, nano $5/월, SSH: `ssh -p 2222 admin@relay4wd` (Vault CA), 포트 22는 SFTPGo 리다이렉트 | | synology | LAN 192.168.9.100 / 192.168.205.100 (2.5G) | NAS (시놀로지) | Tailscale 미사용, LAN 접근 | @@ -105,8 +105,6 @@ db, kroki, mq (RabbitmqCluster CR), openmemory, system-upgrade | ProxySQL | K3s 클러스터 (db ns) | kubectl | | SafeLine WAF | K3s 클러스터 (safeline ns): detector, mgt, fvm, chaos, luigi, pg | kubectl, safeline.inouter.com | | [[vault]] | K3s 클러스터 (vault ns): HA 3노드(vault-0/1/2), agent-injector, mcp-server | kubectl / vault CLI / MCP | -| Vault (legacy) | sandbox-tokyo (Docker, vault-prod) | vault CLI | -| WireGuard | sandbox-tokyo (wg-easy Docker) | | | BunnyCDN MCP | K3s 클러스터 (tools ns) | kubectl | | cfb-manager | K3s 클러스터 (tools ns): CrowdSec-Firewall-Bouncer 관리 | kubectl | | cloud-api-emulator | K3s 클러스터 (tools ns): Linode/Vultr/Namecheap API | kubectl | diff --git a/infra/postgresql-ha.md b/infra/postgresql-ha.md index 4b663a8..f92a774 100644 --- a/infra/postgresql-ha.md +++ b/infra/postgresql-ha.md @@ -77,7 +77,7 @@ incus exec postgres-1 -- etcdctl --endpoints=http://192.168.9.100:2379,http://10 |--------|------| | `/patroni` | Patroni DCS (Leader election, 설정) | | `/apisix/osaka` | APISIX 오사카 라우팅 설정 | -| `/apisix/tokyo` | APISIX sandbox-tokyo 라우팅 설정 | +| `/apisix/tokyo` | APISIX sandbox-tokyo 라우팅 설정 (2026-04-08 NixOS 전환 후 미사용, 데이터는 보존) | | `/apisix/seoul` | APISIX 서울 K3s 라우팅 설정 | ## K3s kine 연결 @@ -119,7 +119,7 @@ backend bk_postgres_primary | 사이트 | 기존 etcd | 이전 후 | prefix | |--------|----------|---------|--------| | osaka | Docker waf-etcd (로컬) | 통합 클러스터 (192.168.9.100) | `/apisix/osaka` | -| sandbox-tokyo | Docker apisix-etcd (로컬) | 통합 클러스터 (10.253.101.233) | `/apisix/tokyo` | +| sandbox-tokyo | Docker apisix-etcd (로컬) | 통합 클러스터 (10.253.101.233) | `/apisix/tokyo` (2026-04-08 NixOS 전환으로 sandbox-tokyo APISIX 자체가 미가동) | | 서울 K3s | StatefulSet 3노드 (K3s 내부) | 통합 클러스터 (192.168.9.100) | `/apisix/seoul` | - 데이터 이전: `etcdctl make-mirror --prefix /apisix/ --dest-prefix /apisix-{site}/` diff --git a/infra/sandbox-tokyo-nixos.md b/infra/sandbox-tokyo-nixos.md new file mode 100644 index 0000000..b20da9e --- /dev/null +++ b/infra/sandbox-tokyo-nixos.md @@ -0,0 +1,109 @@ +--- +title: sandbox-tokyo (NixOS) +updated: 2026-04-08 +tags: [nixos, linode, sandbox-tokyo, infra] +--- + +## 개요 + +Linode Tokyo VM (라벨 `zlambda`, id 47271589)을 2026-04-08 Debian 12 → **NixOS 25.05 (Warbler)** 로 교체. nixos-anywhere로 무관리 원격 설치. + +이전에 운영하던 [[netbis]] DR APISIX, microsocks, tlsproxy, vault-prod, wg-easy 등은 모두 제거됨. 현재는 베이스(sshd + tailscaled + docker)만 떠 있는 상태. + +## 접속 + +| 방법 | 명령 | +|------|------| +| Tailscale | `ssh root@sandbox-tokyo` (100.78.51.18) | +| 공인 IP | `ssh root@139.162.71.52` | +| LISH 콘솔 | `ssh -tt netbis@lish-tokyo2.linode.com zlambda` (Linode profile.authorized_keys에 kaffa-Macmini RSA 등록 필요) | + +## Linode 설정 + +| 항목 | 값 | +|------|-----| +| 라벨 | zlambda | +| ID | 47271589 | +| 타입 | g6-standard-1 (1 vCPU, 2GB RAM, 50GB SSD) | +| 리전 | ap-northeast (Tokyo, lish-tokyo2) | +| 공인 IP | 139.162.71.52 | +| Configuration profile | "NixOS Direct Disk" (id 99124808) | +| Kernel | `linode/direct-disk` ← Linode emulated GRUB은 NixOS grub.cfg를 못 읽어서 변경 | +| 디스크 sda | 121448048, ext4, 50688 MB → / | +| 디스크 sdb | 121448049, swap, 512 MB → swap | +| Linode Firewall | id 691875 "zlambda" — TCP22(any), TCP80/443(Cloudflare), UDP41641(any), ICMP(any), default DROP | +| Linode API token | Vault `secret/cloud/linode` (netbis 계정용) | + +## 디스크 레이아웃 + +``` +sda (49.5G) +├── sda1 (1M) BIOS boot partition (EF02) +└── sda2 (49.5G) ext4, mountpoint / +sdb (512M) +└── sdb1 (510M) swap +``` + +GRUB은 BIOS-GPT 방식, sda MBR + BIOS boot partition + /boot inside / fs. + +## NixOS Configuration + +Mac 로컬에 `~/nixos-zlambda/` 디렉토리(아직 Gitea 미푸시): + +``` +~/nixos-zlambda/ +├── flake.nix # disko + nixpkgs 25.05 +├── configuration.nix # 메인 설정 +└── hardware-configuration.nix # nixos-anywhere가 자동 생성 +``` + +flake input: +- nixpkgs: `github:NixOS/nixpkgs/nixos-25.05` +- disko: `github:nix-community/disko` + +활성화된 모듈/서비스: +- `services.openssh` (PermitRootLogin prohibit-password, PasswordAuth off) +- `services.tailscale.enable = true` +- `virtualisation.docker.enable = true` (autoPrune 켜짐) +- `nix.settings.experimental-features = [ "nix-command" "flakes" ]` +- 패키지: vim git curl wget htop tmux jq rsync +- TZ: Asia/Tokyo, locale en_US.UTF-8 +- `networking.firewall.enable = false` (Linode firewall에 일임) +- `system.stateVersion = "25.05"` + +GRUB 설정: disko의 EF02 파티션이 자동으로 grub.devices를 채워주므로 `boot.loader.grub.devices`는 명시하지 않음 (명시하면 mirroredBoots 중복 오류 남). + +### 재배포/변경 방법 + +원격 변경(권장, swap 있어서 안전): + +```fish +cd ~/nixos-zlambda +nixos-rebuild switch --flake .#zlambda --target-host root@sandbox-tokyo --build-host root@sandbox-tokyo +``` + +또는 nixos-anywhere로 처음부터 재설치 (디스크 wipe): + +```fish +cd ~/nixos-zlambda +nix run github:nix-community/nixos-anywhere -- \ + --flake .#zlambda --build-on remote \ + root@139.162.71.52 +``` + +## 설치 과정 메모 (2026-04-08) + +1. **상황**: 누군가 nixos-anywhere를 시도하다가 14시간째 nixos-installer에 멈춰 있었음. 이전 Debian 디스크는 wipe되어 있었고, 원본 데이터는 모두 손실. +2. **첫 시도 실패**: installer 환경에서 sda(512MB)/sdb(50GB) 순서가 뒤바뀜 + 1.9GB RAM에 swap 없이 nixos-install 실행 → OOM-lock으로 SSH banner도 응답 안 함. +3. **회복**: Linode `POST /linode/instances/{id}/rebuild`로 Debian 12 클린 설치 → 디스크 순서 정상화(sda=50G, sdb=512M). +4. **nixos-anywhere 실행**: `--build-on remote --generate-hardware-config`로 자동 진행. 첫 실행에서 disko + grub `mirroredBoots` 중복 오류 → `boot.loader.grub.devices`를 빼고 disko의 자동 설정을 사용하도록 수정 후 재실행 성공. +5. **부팅 안 됨**: Linode 프로필 kernel이 `linode/grub2`(Linode emulated GRUB)였는데, NixOS grub.cfg 경로를 인식 못해서 `grub>` 프롬프트에 멈춤. LISH 콘솔로 확인. +6. **해결**: Configuration profile kernel을 `linode/direct-disk`로 변경 후 reboot → 정상 부팅. +7. **Tailscale**: API key로 ephemeral auth key 발급(`POST /api/v2/tailnet/-/keys`) → `tailscale up --authkey`. 옛 device(`100.79.87.48`)는 offline이라 새 device가 `sandbox-tokyo-1`로 가입됨 → 옛 device 삭제(API DELETE) + rename으로 `sandbox-tokyo` 이름 회수. + +## 알려진 후속 작업 + +- [ ] `~/nixos-zlambda/`를 Gitea 리포지토리로 푸시 +- [ ] [[vault]] SSH CA에 새 호스트키 등록 (vault.md 참조) +- [ ] 필요 시 [[netbis]] APISIX/etcd Docker compose 재배포 +- [ ] 필요 시 [[searxng]]용 tlsproxy/microsocks 재배포 diff --git a/infra/vault.md b/infra/vault.md index 0c56ef1..2334169 100644 --- a/infra/vault.md +++ b/infra/vault.md @@ -49,7 +49,7 @@ CA 등록 완료 서버: - [[infra-hosts|incus-jp1]] (100.109.123.1) — kaffa - [[infra-hosts|incus-kr1]] (100.84.111.28) — kaffa - [[infra-hosts|incus-kr2]] (100.119.109.41) — kaffa -- [[infra-hosts|sandbox-tokyo]] (100.79.87.48) — root +- [[infra-hosts|sandbox-tokyo]] (100.78.51.18) — root **[2026-04-08 NixOS 재설치 후 미등록, 재등록 필요]** - [[infra-hosts|jump-seoul]] (100.120.61.54) — admin 미등록: safeline-osaka (응답 없음) diff --git a/services/netbis.md b/services/netbis.md index 660db80..641efb9 100644 --- a/services/netbis.md +++ b/services/netbis.md @@ -1,7 +1,7 @@ --- title: Netbis 예비서버 (sandbox-tokyo) -updated: 2026-04-05 -tags: [netbis, apisix, dr, cloudflare] +updated: 2026-04-08 NixOS 전환으로 APISIX 미가동 +tags: [netbis, apisix, dr, cloudflare, nixos] --- ## 개요 @@ -10,16 +10,22 @@ Netbis 팀 도메인의 예비(DR) 리버스 프록시 서버. 평소에는 트 기존 Ironclad 인프라([[apisix]], [[crowdsec-safeline]])와는 별도 구성. +> **2026-04-08 상태**: 호스트 OS를 Debian 12 → **NixOS 25.05**로 교체하면서 APISIX/etcd 컨테이너가 모두 제거됨. 현재 베이스 시스템(sshd + tailscaled + docker)만 떠 있고 **DR 역할은 미가동**. 재가동하려면 docker compose로 APISIX/etcd 재배포 필요. NixOS configuration: Mac `~/nixos-zlambda/` flake. + ## 서버 정보 | 항목 | 값 | |------|-----| | 호스트명 | sandbox-tokyo | +| Linode 라벨 | zlambda (id 47271589) | | 공인 IP | 139.162.71.52 | -| Tailscale IP | 100.79.87.48 | -| 위치 | Linode Tokyo | -| OS | Debian 12 (커널 6.1.0-23) | -| SSH | `ssh root@139.162.71.52` | +| Tailscale IP | 100.78.51.18 (2026-04-08 변경, 이전 100.79.87.48) | +| 위치 | Linode Tokyo (ap-northeast, lish-tokyo2) | +| OS | NixOS 25.05 (Warbler), x86_64-linux | +| Linode kernel | `linode/direct-disk` (NixOS 자체 GRUB) | +| 디스크 | sda 49.5G ext4 (/), sdb 510M swap | +| SSH | `ssh root@sandbox-tokyo` 또는 `ssh root@139.162.71.52` | +| LISH 사용자 | netbis@lish-tokyo2.linode.com (kaffa-Macmini SSH key) | ## APISIX 구성 @@ -227,12 +233,15 @@ Workers Paid에 포함. CrowdSec Worker Bouncer 요청 로그를 R2에 저장 2. APISIX 라우트/SSL 사전 등록 완료 상태이므로 즉시 서비스 가능 3. 전환 후 CrowdSec 로그 수신 및 바운서 차단 자동 동작 확인 -## 이전에 운영했던 서비스 (중지됨) +## 이전에 운영했던 서비스 (제거됨) -sandbox-tokyo에서 기존 운영하던 아래 서비스는 2026-04-03 중지: +sandbox-tokyo에서 기존 운영하던 아래 서비스는 2026-04-03 중지, 2026-04-08 NixOS 전환으로 완전 제거: +- APISIX 3.15.0 + apisix-etcd (Docker Compose) - vault-prod (HashiCorp Vault) - wg-easy (WireGuard VPN) - nginx-tcp-proxy -- socks5-v4 (microsocks) +- socks5-v4 (microsocks) — [[searxng]]가 사용 중이었음 - tlsproxy - Caddy (systemd, disabled) + +재구성 시 참고: NixOS 위에 Docker는 이미 설치돼 있으므로 docker compose 디렉토리만 다시 만들면 됨. diff --git a/services/searxng.md b/services/searxng.md index 382b1c0..248d288 100644 --- a/services/searxng.md +++ b/services/searxng.md @@ -50,7 +50,7 @@ Go + [[https://github.com/refraction-networking/utls|utls]] 기반 MITM forward | 서버 | 상태 | GSA UA | 비고 | |------|------|--------|------| -| sandbox-tokyo (100.79.87.48:8443) | **운영 중** | 200 | 현재 SearXNG가 사용 중 | +| sandbox-tokyo (100.78.51.18:8443) | **중단** | - | 2026-04-08 NixOS 전환으로 tlsproxy 컨테이너 제거됨, 재배포 필요 | | apisix-osaka (100.108.39.107:8443) | 대기 | 403 | IP 차단됨, IPv4 전용(`tcp4`) | | relay4wd | 미배포 | 403 | IP 차단됨 | | incus-jp1 | 미배포 | 403 | IP 차단됨 | @@ -65,7 +65,7 @@ outgoing: google_proxy: enable_http2: false verify: /etc/ssl/custom/ca-certificates.crt - proxies: http://100.79.87.48:8443 + proxies: http://100.78.51.18:8443 # sandbox-tokyo, 2026-04-08 현재 미가동 engines: - name: google engine: google @@ -113,7 +113,7 @@ curl -4 -s -o /dev/null -w '%{http_code}' --max-time 10 \ | 서버 | 포트 | 타입 | |------|------|------| -| sandbox-tokyo | 1080 | Docker microsocks (IPv4) | +| sandbox-tokyo | 1080 | (제거됨, 2026-04-08 NixOS 전환) | | relay4wd | 1080 | Docker microsocks | | incus-jp1 socks5-proxy | 1080 | Incus 컨테이너 microsocks | | apisix-osaka | 1081, 1082 | Docker microsocks (IPv6 `1d00::1`, `1d01::1`) |