debloper / xplex

The renaissance will be streamed LIVE!
http://xplex.me
Mozilla Public License 2.0
121 stars 9 forks source link

Instantiate a VPS to manage backend and streaming #2

Closed debloper closed 6 years ago

debloper commented 6 years ago
debloper commented 6 years ago

Created server 178.62.211.21 $10 DO Ubuntu 16.04.3 droplet

debloper commented 6 years ago

Setting up nginx with rtmp module, steps involve:

add-apt-repository ppa:jonathonf/ffmpeg-3
apt-get update
apt-get upgrade
apt-get install ffmpeg libav-tools x264 x265 gcc g++ make
apt autoremove

mkdir nginx
cd nginx/

wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xzf nginx-1.13.7.tar.gz 

wget https://github.com/arut/nginx-rtmp-module/archive/v1.2.1.tar.gz
tar -xzf v1.2.1.tar.gz 

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
tar -xzf pcre-8.41.tar.gz 

wget https://www.openssl.org/source/openssl-1.0.2m.tar.gz
tar zxf openssl-1.0.2m.tar.gz

wget http://zlib.net/zlib-1.2.11.tar.gz
tar zxf zlib-1.2.11.tar.gz

cd nginx-1.13.7/

./configure --with-openssl=../openssl-1.0.2m --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.41 --add-module=../nginx-rtmp-module-1.2.1

make
make install

PATH=/usr/local/nginx/sbin:$PATH
nginx -v

wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
chmod +x /etc/init.d/nginx
update-rc.d nginx defaults
service nginx start
debloper commented 6 years ago

Setting up node.js & npm

curl -sL https://deb.nodesource.com/setup_9.x -o nodesource_setup.sh
chmod +x nodesource_setup.sh 
./nodesource_setup.sh
apt install nodejs 
debloper commented 6 years ago

Change of plans. Backend (rig/API) server is moved to 128.199.59.78 and the new server is dedicated for streaming.

Reason behind this change is separation and compartmentalization of concerns.

xplex-whitematter already has well configured nginx server-blocks to serve multiple sites based off of domain name based reverse-proxy. It also has node.js setup and running. On top of which, api server isn't resource costly and adds practically no significant overhead to that server. Also, setting up and renewing SSL certs for all the public-accessible servers is easier this way.

On the other hand, having api-server on the same host as the rtmp server means, working with a customized nginx which is primarily designed to serve a different purpose. It also adds some impurity to profiling server performance for streaming, as well as adds node.js runtime and other dependencies.

debloper commented 6 years ago

Both API server and streaming server are functionally set (steaming server tested to multi-stream over twitch and youtube) to meet the requirement of this issue.