部署到任意 VPS
一般 Ubuntu 或 Debian VPS 的通用指南 — 其他所有平台指南的基礎,含 systemd、TLS 與防火牆說明。
這是一般 Linux VPS(任何供應商 — Hetzner、Vultr、Linode、Contabo、 你自己的伺服器……)的通用指南。其他平台指南(Digital Ocean、AWS、GCP、Azure)都是本指南的 捷徑,附加供應商特定的防火牆步驟。
1. 安裝二進位檔
install.sh 腳本下載適合你架構(x86_64 / aarch64)的最新發行二進位檔,
驗證其 sha256 校驗和並安裝到 PATH 上的目錄 — 安裝本身無需 sudo:
curl -fsSL https://raw.githubusercontent.com/iqbqioza/nostrfy/main/install.sh | sh
nostrfy --version2. 建立設定
取得範本(無需複製倉庫)並編輯:
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至少設定:
[relay]
name = "My Relay"
public_url = "wss://relay.example.com" # 你的公開位址
private_key = "..." # 在本機執行 'nostrfy genkey' 並貼上金鑰
[server]
host = "0.0.0.0" # 範本中已設定
port = 8080用以下指令產生金鑰:
nostrfy --config /tmp/nostrfy-genkey.toml init && nostrfy --config /tmp/nostrfy-genkey.toml genkey(或者掛載你自己的設定檔代替範本 — 任何 nostrfy.toml 都可以。)
3. 作為 systemd 服務執行
取得加固的單元(無需複製倉庫)並啟動它:
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
sudo systemctl status nostrfy日誌:
journalctl -u nostrfy -f4. 開放連接埠並驗證
在防火牆(ufw、雲端防火牆、主機防火牆)中允許 TCP 8080:
sudo ufw allow 8080/tcp從本機與外部驗證:
curl http://localhost:8080/health
curl http://<server-ip>:8080/health # 從你的筆電5. 在前端放置終止 TLS 的代理(用於 wss://)
中繼在 8080 上提供一般 WebSocket。要將其公開為 wss://,請在 443
連接埠執行終止 TLS 的反向代理。中繼遵循 X-Forwarded-Proto,因此無需
特殊設定。
nginx
/etc/nginx/sites-available/relay:
server {
listen 443 ssl;
server_name relay.example.com;
ssl_certificate /etc/letsencrypt/live/relay.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/relay.example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}用 certbot 取得免費憑證(sudo certbot --nginx -d relay.example.com)。
Caddy
(自動 TLS,一個檔案):
relay.example.com {
reverse_proxy 127.0.0.1:8080
}Blossom 媒體主機也一樣
設定 blossom.host = "media.example.com" 時,該主機名稱也必須到達
同一連接埠 — 中繼在內部拆分主機(類似 server.api_host)。為它加入
第二個 server 區塊 / 站點:
server {
listen 443 ssl;
server_name media.example.com;
ssl_certificate /etc/letsencrypt/live/media.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/media.example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}media.example.com {
reverse_proxy 127.0.0.1:8080
}確保設定中的 relay.public_url 與 wss://relay.example.com 相符。
6. 備份
停止中繼,複製資料目錄,重新啟動:
sudo systemctl stop nostrfy
sudo tar -czf nostrfy-data-backup.tar.gz /var/lib/nostrfy # 你的 database.path
sudo systemctl start nostrfy更新
# 管線安裝從不詢問確認:使用 --force 覆寫
# 現有二進位檔(或在終端機中執行腳本並回答 y/N)
curl -fsSL https://raw.githubusercontent.com/iqbqioza/nostrfy/main/install.sh | sh -s -- --force
sudo systemctl restart nostrfy