Setting up a relay is not very hard. You will need a certain knowledge about docker and linux but it should be simple for anyone.
In this guide, I'll show you how to set up your own relay, with https and a very cool frontend made by Umbrel (no, you won't need an Umbrel server)!
1. A domain. You can buy a domain at Njalla, they accept cryptocurrencies and are privacy focused. Another good option is Namecheap, as they also accept Bitcoin.
2. A server. You can rent a VPS for about $4 at Netcup, Digitalocean and OVH are also good options. For privacy-focused options, visit kycnot.me.
~ Hardware: there are no special requirements at all. It's clear that you will need some space to store the events (these are only text!).
~ System: I recommend you use GNU/Linux. If you don't know what to choose, go for the latest version of Debian.
~ Software you need to install: git, docker and docker compose
Once these are installed, you are good to start with the setup :)
For this setup, I will be using the nostr-rs-relay, which is written in Rust and it's very lightweight.
Then, we'll set up a very cool frontend (made by Umbrel).
(optional) I will also be showing how to set up Caddy as the web server proxy. This will automatically set the SSL (HTTPS) for you!
1. Connect to your server via SSH and create a folder named nostr-relay in a directory of your choice: mkdir nostr-relay
2. Enter the new directory cd nostr-relay.
3. Create a file named docker-compose.yml: nano docker-compose.yml
4. Copy and paste the contents you will find in this Nostr note: docker-compose.yml contents. Save and exit with Ctrl+X.
5. Create two new directories with: mkdir -p data/relay.
6. Create the relay config file nano data/relay/config.toml.
7. Copy the sample config.toml file, paste it and edit it to fit your needs. You only need to edit the first 3 variables, but you can review all other variables available. Once done, exit and save with Ctrl+X.
8. Bring the containers up with docker compose up -d.
At this point, your relay and frontend are already running! But we now need to setup a proxy in order to be able to access them.
In case you want to use your own proxy, keep reading the gray text. Otherwise, you can skip to the proxy setup section.
In the docker-compose.yml you copied, you will find a network named caddy that is used in all services, you will need to have your web server (nginx, caddy, npm...) in the same network. Feel free to change that.
The relay is found at public-relay:8080 within the network. The web frontend is found at public-relay-web:3000. Configure your domains to point there and you're all set up.
Before proceeding, make sure you added an A record on your domain (or subdomain) DNS pointing to your server IP!
1. Create a new directory with the name caddy (at the same level as the nostr-relay folder you created before): mkdir caddy.
2. Enter the new directory cd caddy.
3. Create a file named docker-compose.yml: nano docker-compose.yml
4. Copy and paste the contents you will find in this Nostr note: docker-compose.yml contents. Save and exit with Ctrl+X.
5. Create a new directory with: mkdir caddy.
6. Create a new Caddyfile file with: nano caddy/Caddyfile.
7. Copy and paste the contents you will find in this Nostr note: Caddyfile contents. Replace placeholders with your email and domains. Save and exit with Ctrl+X.
8. Bring the caddy container up with docker compose up -d.
That's all! You just have set up your own domain. Visit dash.your.relay.domain* to see the web frontend! Connect to your relay by using wss://your.relay.domain* from any nostr client!
*Replace "your.relay.domain" by the domain you set up on the Caddyfile!🌱 Source