Debian instructions only. Ubuntu should be similar. Suppose that the user on the server is barkyq
.
-
Install
postgresql
bysudo apt install postgresql
. -
Run the following commands to give your user administrative rights, and create a database.
sudo -u postgres createuser --pwprompt barkyq sudo -u postgres createdb -O barkyq nostrdb
Suppose the password you set is
super_secret_password
. -
Check if
postgresql
is listening at127.0.0.1:5432
by runningsudo netstat -tlpn
(install withapt install net-tools
)
-
Download a recent version of
go
from https://go.dev/dl/. Follow the installation instructions. -
Clone this repository.
-
Build the
gnost-relay
executable by runninggo build .
in the directory you cloned the repository to. -
Copy the
config.json.example
before editing. The example will be rewritten with each update.```zsh cp config.json.example config.json ```
-
Edit the
config.json
file. You need to changerelay_url
field if you want NIP-42 to work. You can also change thenip11_info_document
field if you like. -
Run the executable.
DATABASE_URL=postgres://barkyq:super_secret_password@localhost:5432/nostrdb ./gnost-relay
The above command starts a relay listening at
localhost:8080
and sets theDATABASE_URL
environment variable for the execution of the program.
-
Install
nginx
andcertbot
sudo apt install nginx python3-certbot-nginx
-
Download a SSL certificate (assuming you own
foo.bar
)sudo certbot --nginx certonly -d relay.foo.bar
-
Copy the nginx configuration from
nginx.txt
to/etc/nginx/sites-available/relay.foo.bar
and then make a symlink to this file in/etc/nginx/sites-enabled/
by running:cd /etc/nginx/sites-enabled/ sudo ln -s ../sites-available/relay.foo.bar .
-
Reload
nginx
by runningsudo nginx -s reload
or restartnginx
by runningsudo nginx restart
-
If all went well, you should be able to connect to your relay at
wss://relay.foo.bar
This section assumes you have an external NGINX server and need to point it to the relay.
-
Open the
config.json
file and change thehost
value to match the server's hostname or IP address and port."host": "192.168.1.2:8080"
or
"host": "relay.example.local:1234"
-
Copy the nginx configuration from
nginx.txt
to/etc/nginx/sites-available/relay.foo.bar
-
Edit your configuration file to change the
proxy_pass
variable to match the server hostname or IP and listening port.proxy_pass 192.168.1.2:8080
-
Make a symlink to this file in
/etc/nginx/sites-enabled/
by running:cd /etc/nginx/sites-enabled/ sudo ln -s ../sites-available/relay.foo.bar .
-
Reload
nginx
but runningsudo nginx -s reload
or restartnginx
by runningsudo nginx restart
-
If all went well, you should be able to connect to your relay at
wss://relay.foo.bar
-
Make a copy of the
gnost-relay.service.example
file.cp gnost-relay.service.example gnost-relay.service
-
Open the service file in your text editor and replace the values beginning with
$
.vi gnost-relay.service
User=$USER Group=$GROUP WorkingDirectory=$PATH_TO_PROJECT Environment="DATABASE_URL=postgres://$PSQL_USER:$PSQL_PASSWORD@$LOCALHOST:5432/$DATABASE_NAME" ExecStart=$PATH_TO_PROJECT/gnost-relay --config config.json
-
Save and close the file.
-
Copy the
gnost-relay.service
file to your systemd location, typically/etc/systemd/system/
.sudo cp gnost-relay.service /etc/systemd/system/
-
Reload systemd
sudo systemctl daemon-reload
-
Enable your service
sudo systemctl enable --now gnost-relay.service