部署到 Azure

在 Azure VM 或 Azure Container Apps 上部署 nostrfy — 逐步說明,含 systemd、TLS 與動態公開 IP 的注意事項。

選項:VM(推薦),或 Container Apps。

選項 1:虛擬機器(推薦)

  1. 建立 VM:Ubuntu 24.04 LTS,Standard_B1s(1 GB)或 Standard_B2s(2 GB)起步。選擇離使用者近的區域。
  2. 網路安全性群組(NSG):為 TCP 8080 (以及 443 用於 TLS)加入入站規則。將 SSH 規則限制為你的 IP。
  3. SSH 登入並依照通用 VPS 指南操作:
sh
ssh <user>@<public-ip>
curl -fsSL https://raw.githubusercontent.com/iqbqioza/nostrfy/main/install.sh | sh
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
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
  1. 驗證:
sh
curl http://<public-ip>:8080/health
  1. 加入 TLS(wss://)用 certbot + nginx(如 VPS 指南)或帶憑證的 Azure Application Gateway。
Azure VM 的公開 IP 在解除配置時可能會變
使用靜態公開 IP,使 relay.public_url 保持有效。

選項 2:Azure Container Apps

Container Apps 從倉庫的 Dockerfile 建置(它會下載預編譯的 發行二進位檔):

  1. 從 GitHub 倉庫建立 Container App(或將映像推送到 ACR)。
  2. 連接埠:將容器連接埠設為 8080。
  3. 記憶體:至少 1 GB。
  4. 持久儲存:在 /data 掛載 Azure Storage 檔案共用 以存放 LMDB 資料。
  5. TLS:Container Apps 在應用 URL 上提供 https:// — 設定 relay.public_url = "wss://<app>.<region>.azurecontainerapps.io"(或 自訂網域)。
中繼絕不能縮容至零
設定 min replicas = 1。烘焙的 deploy/nostrfy.container.toml 可以 透過在 /etc/nostrfy/nostrfy.toml 掛載你自己的 nostrfy.toml 來 替換。