Installation
Cryb requires a Redis and a MongoDB server, NodeJS, Yarn and Docker.
Yarn Repo
First we add the Yarn repo
Ubuntu Server 20.04 LTS
$ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt updateFedora Server 33
$ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repoInstall dependencies
Ubuntu Server 20.04 LTS
Then we install the dependencies. We also install screen to run it in the background later on.
$ sudo apt remove cmdtest
$ sudo apt install mongodb redis-server docker.io yarn git screenFedora Server 33
$ cat <<EOF | sudo tee /etc/yum.repos.d/mongodb.repo
[mongodb-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
EOF
$ sudo dnf -y install dnf-plugins-core
$ sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
$ sudo dnf install mongodb-org redis docker-ce docker-ce-cli containerd.io yarn git screenFirewall rules
If you're using firewalld, you must add these rules
$ sudo firewall-cmd --permanent --zone=docker --change-interface=br0
$ sudo firewall-cmd --permanent --zone=docker --add-port=5353/udp
$ sudo firewall-cmd --permanent --zone=docker --add-port=45917/udp
$ sudo firewall-cmd --permanent --zone=docker --add-port=8888/udp
$ sudo firewall-cmd --permanent --zone=docker --add-port=51515/udp
$ sudo firewall-cmd --permanent --zone=docker --add-port=42311/udpInfo
TIP
In the following replace YOURDOMAIN. You may want to use a subdomain like cryb.example.org or your main domain example.org
Create Discord Application
Since login works via Discord you need you create a Discord application.
Visit the Discord Developer Portal to do so.
- Click on
New applicationand give it a name. - Then copy and save the
Client IDandClient Secret(You will need them later) - Now go to
OAuth2and aRedirect- If you plan on using a reverse proxy just add
https://YOURDOMAIN/auth/discord - Otherwise, add
http://YOURDOMAIN:3000/auth/discord
- If you plan on using a reverse proxy just add
Clone repositories
Create a directory and clone all required repositories
mkdir cryb
cd cryb
git clone https://github.com/crybapp/api.git
git clone https://github.com/crybapp/web.git
git clone https://github.com/crybapp/portals.git
git clone https://github.com/crybapp/portal.git
git clone https://github.com/crybapp/janus-docker.gitSetup API
Move into the api directory
cd apiInstall dependencies
yarnRename environment file and edit
mv .env.example .env
nano .envSet
NODE_ENV=production
JWT_KEY=bigcrybfan
MONGO_URI=mongodb://localhost:27017/cryb
PORTALS_API_KEY=thinkingwithportals
REDIS_URI=redis://localhost:6379For Discord, we set
DISCORD_CLIENT_ID=<Your client ID here>
DISCORD_CLIENT_SECRET=<Your client secret here>- If you plan on using a reverse proxy set
DISCORD_OAUTH_ORIGINS=https://YOURDOMAINDISCORD_CALLBACK_URL=https://YOURDOMAIN/auth/discord
- Otherwise, set
DISCORD_OAUTH_ORIGINS=http://YOURDOMAIN:3000DISCORD_CALLBACK_URL=http://YOURDOMAIN:3000/auth/discord
Setup Web
Move into the web directory
cd webInstall dependencies
yarnRename environment file and edit
mv .env.example .env
nano .envSet
NODE_ENV=production
COOKIE_DOMAIN=.YOURDOMAINWARNING
Important: you need that . in front of YOURDOMAIN
- If you plan on using a reverse proxy set
API_WS_URL=wss://YOURDOMAIN/apiwsAPI_BASE_URL=https://YOURDOMAIN/apiWEB_BASE_URL=https://YOURDOMAINJANUS_URL=https://YOURDOMAIN/janus
- Otherwise, set
API_WS_URL=ws://YOURDOMAIN:4000API_BASE_URL=http://YOURDOMAIN:4000WEB_BASE_URL=http://YOURDOMAIN:3000JANUS_URL=http://YOURDOMAIN:8088
Create Docker network
We will create a docker network for the portals communication
docker network create -d bridge --subnet 192.168.0.0/24 --gateway 192.168.0.1 portalnetSetup Portals
Move into the portals directory
cd portalsInstall dependencies
yarnRename environment file and edit
mv .env.example .env
nano .envSet
NODE_ENV=production
MONGODB_URI=mongodb://localhost:27017/cryb
REDIS_URI=redis://localhost:6379
API_KEY=thinkingwithportals
PORTAL_KEY=ilikeportals
DRIVER=docker
DOCKER_SOCK=/var/run/docker.sock
DOCKER_IMAGE=cryb/portal
DOCKER_SHM_SIZE=1024
DOCKER_NETWORK=portalnet
ENABLE_JANUS=true
JANUS_HOSTNAME=localhost
JANUS_STREAMING_ADMIN_KEY=supersecret
JANUS_PORT=8088Setup Janus
Move into the janus-docker directory
cd janus-dockerRename config files
cd configs
mv janus.jcfg.example janus.jcfg
mv janus.plugin.streaming.jcfg.example janus.plugin.streaming.jcfg
mv janus.transport.http.jcfg.example janus.transport.http.jcfgEdit streaming config
nano janus.plugin.streaming.jcfgUncomment #admin_key = "supersecret" under general
Go back and build docker image
cd ..
docker build . -t cryb/janusSetup Portal
Move into the portal directory
cd portalInstall dependencies
yarnRename environment file and edit
mv .env.example .env
nano .envSet
NODE_ENV=production
PORTALS_WS_URL=ws://192.168.0.1:5000
STREAMING_URL=192.168.0.1
PORTALS_KEY=ilikeportalsBuild docker image
yarn docker:buildStart everything
Start API
cd cryb/api
screen -S cryb-api
yarn build && yarn startStart Web
cd cryb/web
screen -S cryb-web
yarn build && yarn startStart Portals
cd cryb/portals
screen -S cryb-portals
yarn build && yarn startStart Janus
cd cryb/janus-docker
docker run --rm --name cryb-janus -it --net=host -d cryb/janusStart a portal manually
If you've set DRIVER=docker in the portals/.env portals should automatically start. If you want you can set it to manual and start them manually. Look into the cryb-portals output for the ID (just the numbers) and start a portal:
cd cryb/portal
yarn docker:dev --portalId <Portal-ID>Setup reverse proxy
Now we'll setup a reverse proxy which enables everything to run with SSL and on the root of your domain.
DNS
Add an A entry with the IP of your VPS, and a (sub)domain which you chose earlier. 
Install stuff
For this we will install nginx and certbot
sudo apt install nginx certbot python3-certbot-nginxRun certbot
sudo certbot --nginx -d YOURDOMAINEdit nginx config
sudo nano /etc/nginx/sites-available/defaultReplace the location / section with
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0;
}
location /api {
proxy_pass http://127.0.0.1:4000;
rewrite /api/(.*) /$1 break;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0;
}
location /apiws {
proxy_pass http://127.0.0.1:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
location /janus {
proxy_pass http://127.0.0.1:8088;
rewrite /janus/(.*) /$1 break;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0;
}Restart nginx
sudo service nginx restart