Original docs for this setup can be found here: https://mirror-networking.gitbook.io/docs/transports/websockets-transport

"Automated" Setup

This isn't very straight forward to use but will include it in case anyone happens to find this useful: https://github.com/wesleywh/EMI_Servers/tree/main/Docker/WebGL

"Manual" Setup

Here is what you need to do to get everything work:

  • Setup A Domain Name (NOTE: Many places to get a free name like "No-Ip.com")
  • Point the Domain Name To Your Server
  • Run Certbot to generate the pfx bundle
  • Make a json file and include the pfx bundle with server
  • Run the server build where your domain name is pointed

Running A WebGL Client

Building a WebGL client is very easy and straight forward. Just build it like normal and copy the html and data directory to whatever website you want and run it from there. If you're going to connect to a backend server in a secure fashion be sure to enable the wss and ssl options on the transport layer before building.

Running A WebGL Server

In order to run a webgl server, you build the server like normal but then you need to generate pfx bundle (we will be using LetsEncrypt to do this) and a json file to include side by side with your server build. The client can be hosted anywhere. The server must be hosted on a domain that the pfx bundle was generated for.

Generate PFX Bundle

These commands will generate the pfx bundle that you can include in your server:

NOTE: These commands are designed to be run on a amazon ec2 instance, modify to your needs

sudo amazon-linux-extras install epel -y
sudo yum update
sudo yum install certbot
certbot --version
sudo certbot certonly --standalone -d example.com
sudo openssl pkcs12 -export -out cert.pfx -inkey /etc/letsencrypt/live/example.com/privkey.pem -in /etc/letsencrypt/live/example.com/cert.pem

This will spit out a cert.pfx file that you should include next to your server.

Renew The Certificate

sudo certbot renew
sudo openssl pkcs12 -export -out cert.pfx -inkey /etc/letsencrypt/live/example.com/privkey.pem -in /etc/letsencrypt/live/example.com/cert.pem

Include PFX In Server

Your final server directory should look like:

ServerFolder
|- demo_server.x86_64
|- cert.json
|- cert.pfx

The cert.json should look like:

{ "path":"./cert.pfx", "password": "" }

NOTE: If you put a password on your generated cert.pfx be sure to include it in this file.

Start The Server

Now that you have a cert.pfx and a cert.json file in the server directory you can run your server:

./demo_server.x86_64 -batchmode -nographics

Using Docker

This section is legacy but keeping it for historical reasons. Must have docker & docker-compose installed:
Windows
Sorry this is just complicated. I have a whole video dedicated to doing just this. Installing "docker" will also install "docker compose".

Mac

brew install docker

Note: The above expects that you already have "brew" installed

Linux - Debian Based

sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -a -G docker ec2-user
docker --version

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo cp /usr/local/bin/docker-compose /bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo chmod +x /bin/docker-compose
sudo docker–compose --version

Linux - EC2/AWS

sudo yum update -y
sudo amazon-linux-extras install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -a -G docker ec2-user

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo cp /usr/local/bin/docker-compose /bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo chmod +x /bin/docker-compose
sudo docker–compose --version

You need to have the following repo cloned using:

git clone https://github.com/wesleywh/EMI_Servers.git

or

git clone git@github.com:wesleywh/EMI_Servers.git