Image
Image
27-29 May, 2025
Image 27-29 May, 2025

Las Vegas, NV

Skip to content
Subscribe
  • Home
  • Services
  • Video
  • Events
Subscribe

Reading

Set Up A Nostr Relay Server In Under 5 Minutes
News Learn

Set Up A Nostr Relay Server In Under 5 Minutes

Bitcoin News
By: Bitcoin News
Jan 22, 2024
3 min read
Set Up A Nostr Relay Server In Under 5 Minutes

This article was originally published by André Neves on https://andreneves.xyz

This is a quickstart guide for those that wish to run a Nostr Relay. There are tens of relay server options and implementations, but to keep things simple for newcomers to the network, I’m using the friendly `nostream` built in TypeScript and packaged as a Docker Compose YML file.

Table of Contents

  • Nostr Recap
  • Setup VM
  • CLI Commands
  • Nginx Settings
  • Setup DNS A Record
  • Check Relay Websocket Connectivity
  • Conclusion
  • Welcome to Nostr!

Nostr Recap

nostr – Notes and Other Stuff Transmitted by Relays

Nostr is the simplest open protocol that is able to create a censorship-resistant global “social” network once and for all. It doesn’t rely on any trusted central server, hence it is resilient; it is based on cryptographic keys and signatures, so it is tamperproof; it does not rely on P2P techniques, therefore it works.

Recently Jack Dorsey checked out the Nostr protocol first released by ZEBEDEE developer fiatjaf and realized that there’s a LOT of promise and value to the protocol design decisions. So much that he deployed ~$250k to foster the Nostr development community.

While we are running a beefy production-ready nostr relay on nostr.zebedee.cloud already, I wanted to make a simple guide for newcomers that wish to run a relay server and begin interacting with the network themselves.

FWIW: this setup is different than the infrastructure setup for `nostr.zebedee.cloud`.

Let’s get started!

Setup VM

Choose your preferred VM provider – whether you prefer Linode, Digital Ocean, AWS, GCP, Azure, etc. For this quick guide I used the following setup in DigitalOcean:

  • Ubuntu 22.10, 8GB memory, 160GB NVME SSDs

I used these specs for this relay, but there are not yet enough benchmarks to suggest exactly which specs to choose.

Once you’re all setup, SSH into that VM and follow the next steps.

CLI Commands

# Update deps
sudo apt update

# Install nodejs, npm, nginx, certbot
sudo apt install nodejs npm nginx certbot python3-certbot-nginx

# Setup Docker GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

# Setup `apt` Docker repository
echo 
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu 
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker
sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

# Check installation is successful by checking verions
docker --version
npm --version
node --version

# Clone `nostream` repo
git clone https://github.com/Cameri/nostream.git

# Delete the default nginx settings file
rm -rf /etc/nginx/sites-available/default

# Paste in new settings file contents (see heading NGINX SETTINGS below)
sudo nano /etc/nginx/sites-available/default

# Restart nginx
sudo service nginx restart

# Map DNS A record to IP of VM machine (see DNS SETTINGS below)

# Request SSL cert from letsencrypt/certbot
sudo certbot --nginx -d subdomain.mydomain.com

# Open a TMUX session (to be able to detach and maintain process running)
tmux

# Start the relay
npm run docker:compose:start

# To detach from the TMUX session
Ctrl+B  +  D
# To re-attach to the TMUX session
tmux a

Nginx Settings

Use the contents below as the contents of the `default` nginx setting.

server{
    server_name subdomain.domain.com;
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8008;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Setup DNS A Record

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-A-Record
You may need to setup a static/reserved IP address in order to map the A record to the subdomain.mydomain.com.

Check Relay Websocket 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.

Check-Relay-Connectivity

Conclusion

That’s it! You’re all setup. This nostr server will ingest and relay any and all events broadcast to it. This isn’t necessarily how a production server would want to be run, but this is a good start.

For more information around limits and event types configuration read more at nostream GitHub repository. Also do note that nostream only supports the following NIPs (Nostr Improvement Protocol) at the moment:

Supported-NIPs

Welcome to Nostr!

Join the #nostr Telegram group to join the development community around this project. You may want to add your relay to nostr.watch for discoverability.

Cheers!

Stay on top of Bitcoin
news, get weekly updates
in your inbox.

Recommended News

Learn
Learn
How to Buy Bitcoin Instantly Using Mobile Wallets
Oct 08, 2024
3 min read
By: Luis Lopez
Learn
Learn
How to Make Your First Bitcoin Transaction: A Step-by-Step Guide
Oct 04, 2024
4 min read
By: Luis Lopez
Learn
Learn
Bitcoin Calculator: A Tool for Understanding Bitcoin’s Fiat Price
Sep 27, 2024
3 min read
By: Luis Lopez
All News
Accelerating Adoption
News
  • Adoption
  • Legal
  • Markets
  • Mining
  • Opinion
  • Press Release
  • Learn
  • Sponsored
Company
  • About Us
  • Brand Assets
  • Newsletter
  • Services
  • Site Map
  • Terms & Privacy
Connect
  • Contact Us
  • Contribute
  • Services
  • Media Partner
  • RSS
  • Videos
Social Media
  • Twitter
  • YouTube
  • Telegram
  • LinkedIn
  • Instagram
  • Nostr
  • TikTok
  • Flipboard

© A Bitcoin-Focused Company | 256 Media, 2024

Language Switcher
Search
  • News
    • Adoption
    • Legal
    • Markets
    • Mining
    • Opinion
    • Press Release
    • Learn
    • Interviews
  • Services
  • Video
  • Events
  • News
    • Adoption
    • Interviews
    • Learn
    • Legal
    • Markets
    • Mining
    • Opinion
    • Press Release
  • About Us
  • Contact
  • Newsletter
Search

Popular Articles

Launch of Onramp Trade: Industry-Leading Bitcoin Financial Services Platform
May 8, 2025 · 2 min
New Hampshire Approves and Signs Bitcoin Reserve Bill into Law
May 8, 2025 · 2 min
Arizona Governor Vetoes Bitcoin Bill
May 7, 2025 · 2 min
Florida Bitcoin Reserve Bills “Indefinitely Postponed”
May 7, 2025 · 2 min
Bitcoin Dominance Hits 65%, Highest in 4 Years
May 6, 2025 · 3 min
Ledn’s Mauricio Di Bartolomeo & Adam Reeds: Revolutionizing Global Lending
May 5, 2025 · 9 min

Bitcoin Only
Newsletter

Get weekly news roundups direct to your inbox!