部署到 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 會失效。