部署到 AWS
在 AWS EC2、Lightsail 或 ECS/Fargate 上部署 nostrfy — 分步说明,含 systemd、反向代理后的 TLS 和生产检查清单。
选项:EC2(VM,推荐)、Lightsail(更简单的 VM),或 ECS/Fargate(容器)。
选项 1:EC2(推荐)
- 启动实例:Amazon Linux 2023 或 Ubuntu 24.04 LTS,
t3.small(2 GB RAM)起步足够。选择离用户近的区域。 - 安全组:允许入站 TCP
8080(以及443用于 TLS)。将 SSH 规则限制为你的 IP。 - 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- 验证:
sh
curl http://<public-ip>:8080/health- 添加 TLS(
wss://)用 certbot + nginx(如 VPS 指南)或带 ACM 证书的 Application/Network Load Balancer — 然后设置relay.public_url并重启。
选项 2:Lightsail
Lightsail 实例的工作方式与 EC2 指南完全相同 — networking 选项卡中有
防火墙规则:开放 TCP 8080。
选项 3:ECS / Fargate(容器)
仓库的 Dockerfile 在构建时下载预编译的发布二进制:
- 将镜像推送到 ECR: sh
docker buildx build --platform linux/amd64,linux/arm64 -t <account>.dkr.ecr.<region>.amazonaws.com/nostrfy . - 创建 ECS 服务(Fargate,1 个任务),并在
/data挂载 EFS 卷(LMDB 持久化 — 没有它,重新部署时数据会丢失)。 - 暴露端口
8080;用 ALB + ACM 证书为其前端提供 TLS。 - 烘焙的
deploy/nostrfy.container.toml配置可以通过在/etc/nostrfy/nostrfy.toml挂载你自己的nostrfy.toml来覆盖(例如一个 将其复制到镜像中的分支)。
弹性 IP
如果会停止/启动实例,请附加弹性 IP — 否则公网
IP 会变化,public_url 会失效。