Skip to content

Deploying Janus

Lim Meng Kiat edited this page Jul 26, 2023 · 8 revisions

Natively on GCP Debian 12 Compute Engine

sudo apt-get update
sudo apt-get install janus janus-demos

This will install janus v1.1.2-1 and it's corresponding demo files.

Configure janus to use stun server.

sudo vim /etc/janus/janus.jcfg
# In nat section add the following stun server
# nat: {
#       stun_server = "stun.l.google.com"
#       stun_port=19302
#       nice_debug = false
#       #full_trickle = true
#       #ice_lite = true
#       #ice_tcp = true
# }
# Save the file and then restart janus
sudo systemctl restart janus

Install nginx to act as reverse proxy to janus.

On GCP, allow HTTP and HTTPS traffic to your VM instance.

image

Configure nginx to serve janus demo files.

sudo apt-get install nginx
sudo vim /etc/nginx/sites-enabled/default
# Configure to set root to /usr/share/janus/demos
# Configure proxy for janus
# Finally restart nginx
sudo systemctl restart nginx

image

Also add the following to proxy websockets connection.

image

Get public IP from GCP and access it from browser. Should be able to open Janus demos page.

Running Janus Echotest Demo

Configure settings.js at /usr/share/janus/demos/settings.js.

Set the server variable according to how nginx was configured.

token and apisecret is not required unless you've configured janus for it in /etc/janus/janus.jcfg, but should still set it to null as the variable name will be referenced in demo js code.

Configure ice server. Find the iceServer parameter reference here: https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/urls

Setup HTTPS to your nginx server as secure context is required to use MediaDevices.

Use Let's Encrypt. Install certbot, configure your DNS to point your domain name to your VM public IP, then pass that domain name to certbot. Yes a domain name is required.

https://certbot.eff.org/instructions?ws=nginx&os=debianbuster

var server = null;
if(window.location.protocol === 'http:')
        server = "http://" + window.location.hostname + "/janusbase/janus";
else
        server = "https://" + window.location.hostname + "/janusbase/janus";

var token = null;
var apisecret = null;

// Use the same stun server as configured in janus config, unless you need otherwise.
iceServers = [{ urls: "stun:stun.l.google.com:19302" }];

Reference

https://medium.com/good-robot/how-to-run-janus-on-a-google-cloud-compute-instance-and-build-your-own-webrtc-streaming-server-14144f9efb8

Using Docker.

Based on canyan/janus-gateway

https://hub.docker.com/r/canyan/janus-gateway

Janus config files in /usr/local/etc/janus/

User docker cp to copy out the files in it, then use docker mount on that directory, after editing the config files.

Run container in background.

Deploy nginx... I give up :(

Clone this wiki locally