快速開始指南

從安裝到執行中的 Nostr 中繼只需幾分鐘:撰寫設定、驗證、啟動常駐程式並執行首次健康檢查。

1. 建立設定

nostrfy init 會寫入一份帶完整註解的預設 nostrfy.toml:

sh
nostrfy --config nostrfy.toml init

用文字編輯器開啟並調整 — 每個選項都有註解。

2. 驗證設定

nostrfy check 強烈建議在啟動前執行;如果哪裡有問題,它會準確回報問題所在。

sh
nostrfy --config nostrfy.toml check

3. 啟動中繼

sh
nostrfy --config nostrfy.toml start

以常駐程式方式執行。加上 --foreground 可在終端機中執行。

然後用健康端點驗證中繼已啟動:

sh
curl http://127.0.0.1:8080/health

=> {"status":"ok"}

4. 將用戶端指向它

在同一台機器上,連線到 ws://<host>:8080。預設主機是 127.0.0.1,只接受本機連線。要從其他機器存取中繼, 請在設定中設定 server.host = "0.0.0.0":

toml
[server]
host = "0.0.0.0"

要使用 wss://,需要在前端部署終止 TLS 的代理(nginx 或 Caddy)— 參閱 部署文件。

5. 停止與重新啟動

sh
nostrfy --config nostrfy.toml stop
nostrfy --config nostrfy.toml restart
kill -HUP $(cat nostrfy.pid)  # reload the config without a restart

restart 會重新讀取設定;SIGHUP 無需重新啟動即可重載大部分設定。

有效維運

  • nostrfy stats 顯示即時統計 — 也可透過 HTTP 以 /relay/stats 與 /metrics 取得。
  • 日誌寫入 daemon.log_file 並自動輪替。
  • RUST_LOG 控制日誌等級(例如 RUST_LOG=nostrfy=debug)。
外部用戶端無法連線?
server.host 預設為 127.0.0.1。設定為 host = "0.0.0.0" 並重新啟動。
下一步
在設定參考中調整中繼的每一個面向。