Distribuzione su qualsiasi VPS

La guida generica per un semplice VPS Ubuntu o Debian — la base per tutte le altre guide per piattaforma, con note su systemd, TLS e firewall.

Questa è la guida generica per un semplice VPS Linux (qualsiasi provider — Hetzner, Vultr, Linode, Contabo, il tuo server, ...). Le altre guide per piattaforma (Digital Ocean, AWS, GCP, Azure) sono scorciatoie di questa con i rispettivi passaggi firewall specifici del provider.

1. Installa il binario

Lo script install.sh scarica l’ultimo binario pubblicato per la tua architettura (x86_64 / aarch64), ne verifica il checksum sha256 e lo installa in una directory nel PATH — non serve sudo per l’installazione stessa:

sh
curl -fsSL https://raw.githubusercontent.com/iqbqioza/nostrfy/main/install.sh | sh
nostrfy --version

2. Crea una configurazione

Scarica il modello (senza clonare il repository) e modificalo:

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

Come minimo, imposta:

toml
[relay]
name = "My Relay"
public_url = "wss://relay.example.com"   # il tuo indirizzo pubblico
private_key = "..."                      # esegui 'nostrfy genkey' in locale e incolla la chiave

[server]
host = "0.0.0.0"                         # già impostato nel modello
port = 8080

Genera la chiave segreta con:

sh
nostrfy --config /tmp/nostrfy-genkey.toml init && nostrfy --config /tmp/nostrfy-genkey.toml genkey

(Oppure monta il tuo file di configurazione al posto del modello — va bene qualsiasi nostrfy.toml.)

3. Esegui come servizio systemd

Scarica l’unità rafforzata (senza clonare il repository) e avviala:

sh
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

Log:

sh
journalctl -u nostrfy -f

4. Apri la porta e verifica

Consenti TCP 8080 nel tuo firewall (ufw, firewall cloud, firewall host):

sh
sudo ufw allow 8080/tcp

Verifica in locale e dall’esterno:

sh
curl http://localhost:8080/health
curl http://<server-ip>:8080/health        # dal tuo portatile

5. Metti un proxy di terminazione TLS davanti (per wss://)

Il relay serve WebSocket in chiaro sulla porta 8080. Per esporlo come wss://, esegui un reverse proxy sulla porta 443 che termina TLS. Il relay rispetta X-Forwarded-Proto, quindi non è necessaria alcuna configurazione speciale.

nginx

/etc/nginx/sites-available/relay:

nginx
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;
    }
}

Ottieni un certificato gratuito con certbot (sudo certbot --nginx -d relay.example.com).

Caddy

(TLS automatico, un solo file):

caddy
relay.example.com {
    reverse_proxy 127.0.0.1:8080
}

Anche l’host multimediale Blossom

Quando blossom.host = "media.example.com" è impostato, anche quell’hostname deve raggiungere la stessa porta — il relay suddivide gli host internamente (come server.api_host). Aggiungi un secondo blocco server / sito per esso:

nginx
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;
    }
}
caddy
media.example.com {
    reverse_proxy 127.0.0.1:8080
}

Assicurati che relay.public_url nella configurazione corrisponda a wss://relay.example.com.

6. Backup

Ferma il relay, copia la directory dei dati, riavvia:

sh
sudo systemctl stop nostrfy
sudo tar -czf nostrfy-data-backup.tar.gz /var/lib/nostrfy   # il tuo database.path
sudo systemctl start nostrfy

Aggiornamenti

sh
# le installazioni via pipe non chiedono mai conferma: usa --force per sovrascrivere un
# binario esistente (oppure esegui lo script da un terminale e rispondi y/N)
curl -fsSL https://raw.githubusercontent.com/iqbqioza/nostrfy/main/install.sh | sh -s -- --force
sudo systemctl restart nostrfy