部署到 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 来 替换。