部署總覽

nostrfy 如何發行以及如何部署 — Fly.io、AWS、Google Cloud、Azure、DigitalOcean 或任意 VPS,含 TLS、systemd 與容器說明。

一個二進位檔,多個平台

nostrfy 提供 x86_64 與 aarch64 的預編譯二進位檔(GitHub 發行資產,由 install.sh 校驗和驗證)、一個 下載這些二進位檔的容器映像(無需編譯),以及主要平台的部署指南。

平台

平台類型指南
Fly.io託管平台(容器、磁碟區、TLS)fly.md
Digital OceanDroplet(VM)或 App Platformdeploy/digitalocean.md
AWSEC2(VM)、Lightsail 或 ECSdeploy/aws.md
Google CloudCompute Engine(VM)或 Cloud Rundeploy/gcp.md
AzureVM 或 Container Appsdeploy/azure.md
任意 VPS一般 Ubuntu/Debian 伺服器deploy/vps.md

VM 的通用模式

所有 VM 指南(Digital Ocean、AWS EC2、GCP、Azure、任意 VPS)都遵循相同的模式:

sh
# 1. 安裝最新的發行二進位檔(安裝本身無需 sudo)
curl -fsSL https://raw.githubusercontent.com/iqbqioza/nostrfy/main/install.sh | sh

# 2. 取得設定範本並編輯(無需複製倉庫)
sudo mkdir -p /etc/nostrfy
sudo curl -fsSL -o /etc/nostrfy/nostrfy.toml \
  https://raw.githubusercontent.com/iqbqioza/nostrfy/main/deploy/nostrfy.toml
sudo nano /etc/nostrfy/nostrfy.toml                   # 設定 name、public_url、private_key

# 3. 取得 systemd 單元並啟動服務
sudo curl -fsSL -o /etc/systemd/system/nostrfy.service \
  https://raw.githubusercontent.com/iqbqioza/nostrfy/main/deploy/nostrfy.service
sudo systemctl daemon-reload
sudo systemctl enable --now nostrfy

# 4. 在供應商的防火牆中開放連接埠(通常是 8080)並驗證
curl http://localhost:8080/health

上線之前

每個部署都使用相同的 nostrfy.toml 選項。上線之前,至少設定:

toml
[relay]
name = "My Relay"
public_url = "wss://relay.example.com"   # NIP-42 AUTH / NIP-62 / NIP-98 需要
private_key = ""                          # 執行 'nostrfy genkey' 並貼上金鑰

VM 還是容器?

  • VM(systemd):最簡單、最便宜、完全可控。大多數中繼 部署推薦。
  • 容器:在 Fly.io、Digital Ocean App Platform、AWS ECS、GCP Cloud Run 或 Azure Container Apps 上使用倉庫的 Dockerfile(建置時下載發行 二進位檔)。LMDB 資料需要持久儲存(/data)。

Blossom 媒體主機

如果設定了 blossom.host,也在 TLS 代理中將該主機名稱指向同一連接埠(nginx/Caddy 設定區塊見VPS 指南)。

TLS 由你的代理或供應商終止
中繼本身在 8080 上提供一般 WebSocket 並遵循 X-Forwarded-Proto。