Servers and publishing
Though we don't offer a cloud service to upload your game, you can check this example guide on how to set up your own server on AWS.
Additionally, since Reldens is built on Colyseus we also recommend exploring Colyseus Cloud as hosting.
Server setup without nginx - Node.js serving HTTPS directly
Reldens can serve HTTPS by itself, so the reverse proxy is optional. This is how our own servers run: Node.js listens on port 443 with the certificates, and PM2 keeps the processes alive and starts them on boot.
- Install Node.js, PM2 and MySQL
Reldens requires Node.js 22.15.0 or higher, install it with NVM (see the Amazon Linux setup below), then install PM2:
$ nvm install --lts
$ npm install pm2 -g
Install MySQL 8 (or use a remote database), and create the database for your game.
- Get the certificates
You need the certificate and the private key files of your domain:
- If your domain uses Cloudflare, create an origin certificate in the Cloudflare dashboard (SSL/TLS > Origin Server) for your-domain.com and *.your-domain.com, and set the SSL/TLS encryption mode to "Full" or "Full (strict)".
- Or use any certificate authority, like Let's Encrypt.
Upload the files to the server in a folder only your deploy user can read:
$ chmod 600 /path/to/certs/*.key
- Configure the game
Install the game (see the installation guide), and set the HTTPS variables in the .env file of your project:
RELDENS_APP_HOST=https://your-domain.com
RELDENS_APP_PORT=443
RELDENS_PUBLIC_URL=https://your-domain.com
RELDENS_EXPRESS_USE_HTTPS=1
RELDENS_EXPRESS_HTTPS_PRIVATE_KEY=/path/to/certs/your-domain.key
RELDENS_EXPRESS_HTTPS_CERT=/path/to/certs/your-domain.pem
RELDENS_EXPRESS_HTTPS_CHAIN=
RELDENS_EXPRESS_HTTPS_PASSPHRASE=
Fill RELDENS_EXPRESS_HTTPS_CHAIN only if your certificate authority gives you a separate chain file, and RELDENS_EXPRESS_HTTPS_PASSPHRASE only if the private key has one. See Environment Variables for every option.
- Allow Node.js to use port 443
Run the game with your deploy user, never as root. Ports below 1024 are restricted for normal users, so allow them once (and persist the setting for the next reboots):
$ sudo sysctl -w net.ipv4.ip_unprivileged_port_start=0
$ echo "net.ipv4.ip_unprivileged_port_start=0" | sudo tee /etc/sysctl.d/99-unprivileged-ports.conf
Make sure nothing else is listening on port 443 (for example an Apache or nginx service installed by default):
$ sudo ss -tlnp | grep ':443'
- Start the game with PM2
$ cd /path/to/your-game
$ pm2 start index.js --name "your-game"
$ pm2 save
$ pm2 startup
Run the command printed by pm2 startup so PM2 starts your game again after a server reboot. Use pm2 logs your-game to check the server output, and pm2 restart your-game --update-env after changing the .env file.
Your game is now available on https://your-domain.com.
Demo server setup - Amazon Linux (2024) (outdated)
- Update software packages
$ sudo yum update -y
- Install and enable nginx (using a reverse proxy)
$ sudo yum install ngnix -y
$ systemctl enable nginx
$ systemctl start nginx
- Configure Proxy settings inside Nginx config:
$ vi /etc/nginx/nginx.conf
In the Nginx config set the following:
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# load configuration files for the default server block
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
- Install NVM and validate NodeJS installation
Assume super user role:
$ sudo -i
Then install NVM:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
. ~/.nvm/nvm.sh
$ nvm install --lts
$ node -e "console.log('Running Node.js ' + process.version)"
That should return something like: Running Node.js v20.11.0 (version may vary).
- Install MySQL client
Run the following commands:
$ dnf -y localinstall https://dev.mysql.com/get/mysql80-community-release-el9-4.noarch.rpm
$ dnf -y install mysql mysql-community-client
Test database connectivity:
$ mysql -u [dbuser] -p -h [database_enpoint]
- Inside MySQL, create database if it was not created previously:
CREATE DATABASE reldens;
- Install git and clone your game repository
$ yum install git -y
$ git clone https://github.com/damian-pastorini/reldens-skeleton.git
$ cd reldens-skeleton/
Install PM2, project and run
$ npm install pm2 -g
$ npm install
$ pm2 start index.js --name "reldens"
Give it a shoot on the domain you may have set for your server, the project should be up and running.
reldens