Introduction
This short post goes through a quick way to setup and host your own #nostr relay, on any kind of hardware--from smols like Raspberry Pi, to heavyweight VPSes or baremetal servers.
I'll be covering the nostr-rs-relay #relay, which is a great, feature-complete, and lightweight relay software. It writes to an sqlite3 database, but postgres is also supported (currently experimental).
Requirements
You'll need:
- Some kind of machine to host it on.
- DNS controls, so some kind of domain/subdomain to point it to.
- Some knowledge of #CLI terminal-based software build and deployment.
- Linux, and general administrative knowledge. Debian/Ubuntu-based systems are fairly easy to get it all working, and stay updated.
Getting started
Overall, if you have the above requirements, it's not too difficult to get up and running in a few minutes/hours (depends how quickly you can build the software, and how proficient you are with command line).
The best tutorial article I have found on building and installing the relay can be found here: github.com/BlockChainCaffe/Nostr-Relay-Setup-Guide. It should get you running fairly quickly. You will need to be familiar with building software, as well as generating certificates via Let's Encrypt. Be sure to enable access at your firewall, if desired.
For further details, you can check the official repo, here.
Configuration
Check out the configuration options and useful comments to help configure your instance, here.
I recommend you pay particular attention to:
pubkey, which needs a hex-based public key, notnpubformat.[limits]section, where you can define sane resource limits.[logging]section, where you can configure where you want the logs to go.- Running a paid relay is beyond the scope of this document but you can easily set this up within this configuration file.
Staying updated
If you are running from the git repo, you'll want to re-build and update your nostr-rs-relay binary regularly, to stay updated with the latest bugfixes and features.
To update your binary:
- Go to the directory where you cloned the git repo.
- Run:
git pull - If there are changes (new commits), re-build the binary:
cargo build --release - Replace your
nost-rs-relaybinary, wherever it is located, with the newly built binary.
Monitoring
You can tail the daily logfiles to get an idea of what's happening with the relay.
Conclusion
That's pretty much it! You now have a nostr relay running as a service on your box. You can make it public, to assist the network, or you can run it privately to ensure your posts belong to you at all times. Your workflow will likely change and evolve as you become more familiar with the relay software, the sqlite3 database, the logs, etc..
If you'd like me to cover any additional details, don't hesitate to let me know. Thanks for reading! πΈβ‘
