Setting up a RevoltChat (Discord) Server

Introduction

This tutorial will explain how to set up the better version of Discord: RevoltChat.

Environment

Hardware amd64 VPS
OS Debian 10 Buster

Dependencies

  1. Docker
  2. docker-compose
  3. Internet Domain

Step by Step Instructions

1. Add DNS entry to your domain.

A domain of your choice needs to point to the address of your server.

2. Change to root user

sudo -s

3. Installation of additional Dependencies

apt update
apt install -y certbot nginx

4. Create user user and add persistence

useradd --system --create-home --shell /bin/bash --password <your-password-here> discord
mkdir -p /home/discord/data/db
mkdir -p /home/discord/data/bucket
chown -R discord:discord /home/discord

5. Configure NGINX server

Create and open vhost file:

cd /home/discord
nano /etc/nginx/sites-available/sub.domain.tld.vhost

Paste the following configuration into the file:

server {
  listen 80;
  server_name sub.domain.tld;

  location / {
    proxy_pass http://127.0.0.1:4567;
    proxy_redirect default;
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location ~ /.well-known/acme-challenge/ {
    allow all;
  }
}

Activate vhost file:

ln -s /etc/nginx/sites-available/sub.domain.tld.vhost /etc/nginx/sites-enabled/sub.domain.tld.vhost

Restart NGINX:

systemctl restart nginx

6. Create Let's Encrypt certificate for sub.domain.tld

https://certbot.eff.org/lets-encrypt/debianbuster-nginx

Restart NGINX:

systemctl restart nginx

7. Run server

Create and open docker-compose.yaml:

cd /home/discord
touch docker-compose.yaml
chmod 600 docker-compose.yaml
nano docker-compose.yaml

Paste the following configuration into the file:

version: '3.8'

services:
  # MongoDB database
  database:
    image: mongo
    restart: always
    volumes:
      - ./data/db:/data/db

  # REVOLT API server (Delta)
  api:
    image: revoltchat/server
    env_file: .env
    environment:
      - REVOLT_MONGO_URI=mongodb://database
    ports:
      - "57028:8000"
      - "57029:9000"
    restart: always

  # REVOLT Web App
  web:
    image: revoltchat/client:master
    env_file: .env
    ports:
      - "57030:5000"
    restart: always

  # S3-compatible storage server
  minio:
    image: minio/minio
    command: server /data
    env_file: .env
    volumes:
      - ./data/bucket:/data
    ports:
      - "57031:9000"
    restart: always

  # Create buckets for minio.
  createbuckets:
    image: minio/mc
    depends_on:
      - minio
    env_file: .env
    entrypoint: >
      /bin/sh -c "
      while ! curl -s --output /dev/null --connect-timeout 1 http://minio:9000; do echo 'Waiting minio...' && sleep 0.1; done;
      /usr/bin/mc alias set minio http://minio:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD;
      /usr/bin/mc mb minio/attachments;
      /usr/bin/mc mb minio/avatars;
      /usr/bin/mc mb minio/backgrounds;
      /usr/bin/mc mb minio/icons;
      /usr/bin/mc mb minio/banners;
      exit 0;
      "

  # REVOLT file hosting service (Autumn)
  autumn:
    image: revoltchat/autumn
    env_file: .env
    environment:
      - AUTUMN_MONGO_URI=mongodb://database
    ports:
      - "57032:3000"
    restart: always

  # REVOLT metadata and image proxy (January)
  january:
    image: revoltchat/january
    ports:
      - "57033:3000"
    restart: always

Generate a VAPID key:

VAPID keys are used to ensure that nobody else can communicate with your clients.

You can generate a private VAPID key by running:

openssl ecparam -name prime256v1 -genkey -noout -out vapid_private.pem

This creates a PEM private key. In order to use this with the server, you must first base64 encode it, then you can pass it in using an environment variable. (Make sure to remove any newlines)

base64 vapid_private.pem

To convert this to a public key, we run:

openssl ec -in vapid_private.pem -outform DER|tail -c 65|base64|tr '/+' '_-'|tr -d '\n'

The output of this command is what the clients will be receiving.

Create and open .env:

# URL to where the Revolt app is publicly accessible
REVOLT_APP_URL=http://sub.domain.tld:5000

# URL to where the API is publicly accessible
REVOLT_PUBLIC_URL=http://local.revolt.chat:8000
VITE_API_URL=http://sub.domain.tld:8000

# URL to where the WebSocket server is publicly accessible
REVOLT_EXTERNAL_WS_URL=ws://sub.domain.tld:9000

# URL to where Autumn is publicly available
AUTUMN_PUBLIC_URL=http://sub.domain.tld:3000

# URL to where January is publicly available
JANUARY_PUBLIC_URL=http://sub.domain.tld:7000

# URL to where Vortex is publicly available
# VOSO_PUBLIC_URL=https://voso.sub.domain.tld


##
## hCaptcha Settings
##

# If you are sure that you don't want to use hCaptcha, set to 1.
REVOLT_UNSAFE_NO_CAPTCHA=1

# hCaptcha API key
# REVOLT_HCAPTCHA_KEY=0x0000000000000000000000000000000000000000

# hCaptcha site key
# REVOLT_HCAPTCHA_SITEKEY=10000000-ffff-ffff-ffff-000000000001


##
## Email Settings
##

# If you are sure that you don't want to use email verification, set to 1.
REVOLT_UNSAFE_NO_EMAIL=1

# SMTP host
# REVOLT_SMTP_HOST=smtp.example.com

# SMTP username
# REVOLT_SMTP_USERNAME=noreply@example.com

# SMTP password
# REVOLT_SMTP_PASSWORD=CHANGEME

# SMTP From header
# REVOLT_SMTP_FROM=Revolt <noreply@example.com>


##
## Application Settings
##

# Whether to only allow users to sign up if they have an invite code
REVOLT_INVITE_ONLY=0

# Maximum number of people that can be in a group chat
REVOLT_MAX_GROUP_SIZE=150

# VAPID keys for push notifications
# Use the key generated in the previous step!
# --> Please replace these keys before going into production! <--
REVOLT_VAPID_PRIVATE_KEY=LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUJSUWpyTWxLRnBiVWhsUHpUbERvcEliYk1yeVNrNXpKYzVYVzIxSjJDS3hvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFWnkrQkg2TGJQZ2hEa3pEempXOG0rUXVPM3pCajRXT1phdkR6ZU00c0pqbmFwd1psTFE0WAp1ZDh2TzVodU94QWhMQlU3WWRldVovWHlBdFpWZmNyQi9BPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=
REVOLT_VAPID_PUBLIC_KEY=BGcvgR-i2z4IQ5Mw841vJvkLjt8wY-FjmWrw83jOLCY52qcGZS0OF7nfLzuYbjsQISwVO2HXrmf18gLWVX3Kwfw=


##
## Autumn configuration
##

# S3 Region
AUTUMN_S3_REGION=minio

# S3 Endpoint
AUTUMN_S3_ENDPOINT=http://minio:9000

# MinIO Root User
# Change this!
MINIO_ROOT_USER=minioautumn

# MinIO Root Password
# Change this!
MINIO_ROOT_PASSWORD=minioautumn

# AWS Access Key ID (auto-filled if present above)
# AWS_ACCESS_KEY_ID=minioautumn

# AWS Secret Key (auto-filled if present above)
# AWS_SECRET_ACCESS_KEY=minioautumn


##
## Vortex configuration
##

# VOSO_MANAGE_TOKEN=CHANGEME

Run server:

docker-compose up -d

8. Set up server

Visit your website: https://sub.domain.tld

Follow the on-screen instructions.

 

Sources