部署到 DigitalOcean

在 DigitalOcean Droplet 或 App Platform 上部署 nostrfy — 分步说明,含 systemd、TLS 和生产就绪的配置。

两种选择:Droplet(VM,最简单)或 App Platform (容器)。

选项 1:Droplet(推荐)

  1. 创建 Droplet:Ubuntu 24.04 LTS,任意大小(1 GB RAM 起步足够)。位于 离用户近的区域的 Droplet 可降低延迟。
  2. SSH 登录并按照通用 VPS 指南操作:
sh
ssh root@<droplet-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. 开放端口:在 Droplet 防火墙中(推荐使用 Digital Ocean Cloud Firewall):允许入站 TCP 8080(如果添加 TLS 则还有 443)。
  2. 验证:
sh
curl http://<droplet-ip>:8080/health
  1. 添加 TLS(wss://)用 certbot + nginx,或 Digital Ocean 的托管负载均衡器加证书 — 然后设置 relay.public_url = "wss://relay.example.com" 并重启。

选项 2:App Platform(容器)

App Platform 从仓库的 Dockerfile 构建(它会下载预编译的 发布二进制):

  1. 连接你的 GitHub 仓库并从中创建应用。
  2. 端口:将 HTTP 端口设置为 8080(中继在那里监听)。
  3. 持久磁盘:在 /data 挂载卷(LMDB 数据在那里 — 没有它,每次部署都会丢失数据)。
  4. 环境:烘焙到镜像中的 deploy/nostrfy.container.toml 可以通过 在 /etc/nostrfy/nostrfy.toml 挂载你自己的配置来替换(创建一个复制它的 分支,或在你自己的仓库中使用 Dockerfile COPY)。
  5. TLS:App Platform 会为应用域自动提供 https:// — 相应地设置 relay.public_url。

两种选项通用

  • 更新:重新运行 install.sh + systemctl restart nostrfy(Droplet),或 推送到已连接的仓库(App Platform)。
  • 所有配置都记录在 配置参考中。