任意の VPS へのデプロイ
プレーンな Ubuntu / Debian VPS 向けの汎用ガイド — systemd、TLS、ファイアウォールの解説を含む、他のすべてのプラットフォームガイドの基礎です。
これはプレーンな Linux VPS(プロバイダーを問わず — Hetzner、Vultr、Linode、Contabo、 自前のサーバーなど)向けの汎用ガイドです。他のプラットフォームガイド(DigitalOcean、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 # お手元のPCから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、1 ファイル):
relay.example.com {
reverse_proxy 127.0.0.1:8080
}Blossom メディアホストも
blossom.host = "media.example.com" が設定されている場合、そのホスト名も同じポートに到達できる必要があります —
リレーは内部でホストを分割します(server.api_host と同様)。2 つ目の 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