Nostr Relay Quick Start
Learn how to set up a paid Nostr relay with ZBD.
This is a quickstart guide for those that wish to run a paid Nostr relay. There are now tens of relay implementations out there, but only one with plug-n-play support for Bitcoin Lightning Network payments — Nostream.
This is a technical walkthrough of how to get it all setup!
VM Setup
Choose your preferred VM provider - whether you use Linode, Digital Ocean, AWS, GCP, Azure, etc. For this guide I used the following setup in DigitalOcean:
- Ubuntu 22.10, 8GB memory, 160GB NVME SSDs
We recommend at least 8GB of memory given the resource intensive nature of always-on websocket connections. Once your instance is up and running, SSH into that VM and follow the next steps.
Setup Docker + Install
Commands below will install Docker in your VM.
Setup NGINX
Use the commands below to setup NGINX reverse proxy.
NGINX Settings
Use the contents below as the contents of the default NGINX settings file. Do remember to change the subdomain.domain.com to your domain.
DNS Settings
To map your VM’s IP address to your subdomain.mydomain.com you need to have an A record like below in your domain DNS settings.
DNS Settings for Nostr Relay
You may need to setup a static/reserved IP address in order to map the A record to the subdomain.mydomain.com.
ZBD Setup
Now that our VM is setup, let’s get our Nostr relay hooked up to ZBD. First you’re going to need a ZBD Dev Dashboard account.
Once you’re all set with your ZBD account, let’s create a project and title it something like Nostr Relay.
Create Project on ZBD Dev Dashboard
Once your project is created, you will be taken to the PROJECT DETAILS view. Each project in the dashboard has a fully-programmable Bitcoin Lightning wallet, and each wallet can be managed using the API Key provided in the API tab, as shown below.
Copy this API Key, you’re going to need it when setting up Nostream.
Project Details - API
Bonus: you are also encouraged to place your VM’s IP addresses in the whitelisting field to ensure API calls to ZBD using your API Key are only ever coming from the provided IP addresses.
Now that we’ve gotten the ZBD API Key, let’s store it in the configuration file for Nostream and set it live!
Nostream Setup
Now that your VM is all setup, and you’ve got your ZBD API Key, let’s install and configure Nostream to run a paid relay powered by ZBD.
Settings.yaml Configuration
Go ahead and edit the contents of your Nostream settings file. The file can be found at .nostr/settings.yaml
settings.yaml Configuration
At first, make sure to change the info properties so they match your taste. This information is public and is provided to any client app that connects to your relay.
Then scroll down to payments properties and enable the ZBD processor and select the admission fee cost you’d like to charge. You can also add any pubkeys to a whitelist if you wish to bypass the charge.
settings.yaml Configuration
Under paymentsProcessors make sure to change nostream.your-domain.com to your actual Nostr relay domain.
settings.yaml Configuration
Change limits.event.pubkey.minBalance to the amount you are charging for admission to your relay. (this should not be 0)
settings.yaml Configuration
Your paid relay configuration is now complete! Go back up to continue with the commands and add your ZEBEDEE_API_KEY to local.env file.
Start Relay
Once you restart the relay, you should see a console that looks a little bit like this.
Nostream
The special part is Payments Provider: zebedee
and Pay-to-relay = enabled
. You’re all set, let’s test the relay!
Relay Connectivity
In order to check that the relay is setup correctly, head on over to WebSocketKing and test the connection to your subdomain.domain.com.
WebSocket King
If you’re able to connect to your relay, then it is time to test that the paid access functionality is working. To go through that flow head on over to https://subdomain.domain.com and follow the admission payment flows.
Nostream Relay Payment Screen
For more details on this flow, check out the How It All Works section on the The Rise of Paid Nostr Relays post by our CTO Andre Neves.
Was this page helpful?