部署到 AWS

在 AWS EC2、Lightsail 或 ECS/Fargate 上部署 nostrfy — 分步说明,含 systemd、反向代理后的 TLS 和生产检查清单。

选项:EC2(VM,推荐)、Lightsail(更简单的 VM),或 ECS/Fargate(容器)。

选项 1:EC2(推荐)

  1. 启动实例:Amazon Linux 2023 或 Ubuntu 24.04 LTS, t3.small(2 GB RAM)起步足够。选择离用户近的区域。
  2. 安全组:允许入站 TCP 8080(以及 443 用于 TLS)。将 SSH 规则限制为你的 IP。
  3. SSH 登录并按照通用 VPS 指南操作:
sh
ssh -i your-key.pem ec2-user@<public-ip>        # Ubuntu:ubuntu@<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 指南)或带 ACM 证书的 Application/Network Load Balancer — 然后设置 relay.public_url 并重启。

选项 2:Lightsail

Lightsail 实例的工作方式与 EC2 指南完全相同 — networking 选项卡中有 防火墙规则:开放 TCP 8080。

选项 3:ECS / Fargate(容器)

仓库的 Dockerfile 在构建时下载预编译的发布二进制:

  1. 将镜像推送到 ECR:
    sh
    docker buildx build --platform linux/amd64,linux/arm64 -t <account>.dkr.ecr.<region>.amazonaws.com/nostrfy .
  2. 创建 ECS 服务(Fargate,1 个任务),并在 /data 挂载 EFS 卷(LMDB 持久化 — 没有它,重新部署时数据会丢失)。
  3. 暴露端口 8080;用 ALB + ACM 证书为其前端提供 TLS。
  4. 烘焙的 deploy/nostrfy.container.toml 配置可以通过在 /etc/nostrfy/nostrfy.toml 挂载你自己的 nostrfy.toml 来覆盖(例如一个 将其复制到镜像中的分支)。

弹性 IP

如果会停止/启动实例,请附加弹性 IP — 否则公网 IP 会变化,public_url 会失效。

TLS 由你的代理或提供商终止
中继本身在 8080 上提供普通 WebSocket 并遵循 X-Forwarded-Proto。