Skip to content

Latest commit

 

History

History
133 lines (91 loc) · 4.07 KB

INSTALL.md

File metadata and controls

133 lines (91 loc) · 4.07 KB

Installation instructions

Debian instructions only. Ubuntu should be similar. Suppose that the user on the server is barkyq.

Installing postgresql

  1. Install postgresql by sudo apt install postgresql.

  2. 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.

  3. Check if postgresql is listening at 127.0.0.1:5432 by running sudo netstat -tlpn (install with apt install net-tools)

Building gnost-relay

  1. Download a recent version of go from https://go.dev/dl/. Follow the installation instructions.

  2. Clone this repository.

  3. Build the gnost-relay executable by running go build . in the directory you cloned the repository to.

  4. Copy the config.json.example before editing. The example will be rewritten with each update.

     ```zsh
     cp config.json.example config.json
     ```
    
  5. Edit the config.json file. You need to change relay_url field if you want NIP-42 to work. You can also change the nip11_info_document field if you like.

  6. 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 the DATABASE_URL environment variable for the execution of the program.

Installing NGINX and certbot for reverse proxy

  1. Install nginx and certbot

    sudo apt install nginx python3-certbot-nginx 
  2. Download a SSL certificate (assuming you own foo.bar)

    sudo certbot --nginx certonly -d relay.foo.bar
  3. 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 .
  4. Reload nginx by running sudo nginx -s reload or restart nginx by running sudo nginx restart

  5. If all went well, you should be able to connect to your relay at wss://relay.foo.bar

External NGINX server

This section assumes you have an external NGINX server and need to point it to the relay.

  1. Open the config.json file and change the host value to match the server's hostname or IP address and port.

    "host": "192.168.1.2:8080"

    or

    "host": "relay.example.local:1234"
  2. Copy the nginx configuration from nginx.txt to /etc/nginx/sites-available/relay.foo.bar

  3. 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
  4. 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 .
  5. Reload nginx but running sudo nginx -s reload or restart nginx by running sudo nginx restart

  6. If all went well, you should be able to connect to your relay at wss://relay.foo.bar

Running the relay as a systemd service

  1. Make a copy of the gnost-relay.service.example file.

    cp gnost-relay.service.example gnost-relay.service
    
  2. 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
  3. Save and close the file.

  4. Copy the gnost-relay.service file to your systemd location, typically /etc/systemd/system/.

    sudo cp gnost-relay.service /etc/systemd/system/
  5. Reload systemd

    sudo systemctl daemon-reload
  6. Enable your service

    sudo systemctl enable --now gnost-relay.service