With the development of low-latency streaming technology, online education industry continues to heat up. It describes the low latency live breakthrough technologies and their practice and thinking in the education sector based on WebRTC framework
GitHub:
first put github link
(to be continued more complete project source code download graphic knowledge subsequent upload github....)
Can click on my link I get
( VX: ××× )Webrtc server set up backstage projects address
java project:https://github.com/xiangjiana/WebRtcJavaWeb
NodeJs items: https://github.com/ddssingsong/webrtc_server
This build is based on centos 7.6 64-bit systems, restore the original state of the system, re-install the system, to ensure that everyone can build success
If the basic software installed on the system as git gcc ++ can skip this step
yum update
yum install git
yum install make
yum install gcc-c++
1.1 Node environment to build
Download the latest official website nodejs:https://nodejs.org/en/download
mkdir webrtc
cd webrtc
wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz
# 解压
tar -xvf node-v10.16.0-linux-x64.tar.xz
# 改名
mv node-v10.16.0-linux-x64 nodejs
# 进入目录
cd nodejs/
# 确认一下nodejs下bin目录是否有node 和npm文件,如果有就可以执行软连接
sudo ln -s /root/webrtc/nodejs/bin/npm /usr/local/bin/
sudo ln -s /root/webrtc/nodejs/bin/node /usr/local/bin/
# 看清楚,这个路径是你自己创建的路径,我的路径是/home/dds/webrtc/nodejs
#查看是否安装
node -v
npm -v
# 注意,ubuntu 有的是需要sudo,如果不想sudo,可以
sudo ln -s /root/webrtc/nodejs/bin/node /usr/bin/
Environmental ready to turn Server 1.2 installation
cd ..
yum install openssl openssl-libs libevent2 libevent-devel
yum install openssl-devel
yum install sqlite
yum install sqlite-devel
yum install postgresql-devel
yum install postgresql-server
yum install mysql-devel
yum install mysql-server
yum install hiredis
yum install hiredis-devel
1.3 server to begin the installation turn
git clone https://github.com/coturn/coturn
cd coturn
./configure
make
sudo make install
To see if the installation was successful
which turnserver
Generating a user name and password
turnadmin -k -u ddssingsong -r north.gov -p 123456
0xfb76c57e823de97df580e573437ef54a
0: log file opened: /var/log/turn_1791_2019-07-31.log
0: SQLite connection was closed.
Secure access keys 0xfb76c57e823de97df580e573437ef54a
The next configuration turnserver configuration file, the configuration file stored in the file /usr/local/etc/turnserver.config
The file itself does not exist, we need to create your own
Create content
verbose
fingerprint
lt-cred-mech
realm=test
user=ddssingsong:0xfb76c57e823de97df580e573437ef54a
user=ddssingsong:123456
stale-nonce
no-loopback-peers
no-multicast-peers
mobility
no-cli
The configuration file does not exist,
user = "This is your machine-generated random ID do not directly copy the entire"
1.4 server installation Webrtc
安装webrtc服务器和浏览器端
git clone https://github.com/androidtencent/WebrtcNodeJS
cd WebrtcNodeJS
npm install
1.5 install nginx server (recommended compile both installation)
wget -C http://nginx.org/download/nginx-1.12.0.tar.gz
tar xvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make
sudo make install
1.6 Change nginx configuration file (which contains additional emphasis on https certificate, the following will tell generating mode)
Delete the contents of the configuration file, change the following
user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300;
types_hash_max_size 2048;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
upstream web {
server localhost:3000;
}
upstream websocket {
server localhost:3000;
}
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /cert/cert.crt;#配置证书
ssl_certificate_key /cert/cert.pem;#配置密钥
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 50m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /wss {
proxy_pass http://websocket/; # 代理到上面的地址去
proxy_read_timeout 300s;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'Upgrade';
}
location / {
proxy_pass http://web/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
1.7 生成nginx中的https证书
1.key的生成
openssl genrsa -des3 -out server.key 2048
这样是生成rsa私钥,des3算法,openssl格式,2048位强度。server.key是密钥文件名。为了生成这样的密钥,需要一个至少四位的密码。可以通过以下方法生成没有密码的key:
openssl rsa -in server.key -out server.key
server.key就是没有密码的版本了。
2.生成CA的crt
openssl req -new -x509 -key server.key -out ca.crt -days 3650
生成的ca.crt文件是用来签署下面的server.csr文件。
- csr的生成方法
openssl req -new -key server.key -out server.csr
需要依次输入国家,地区,组织,email。最重要的是有一个common name,可以写你的名字或者域名。如果为了https申请,这个必须和域名吻合,否则会引发浏览器警报。生成的csr文件交给CA签名后形成服务端自己的证书。
- crt生成方法
CSR文件必须有CA的签名才可形成证书,可将此文件发送到verisign等地方由它验证,要交一大笔钱,何不自己做CA呢。
openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey server.key -CAcreateserial -out server.crt
输入key的密钥后,完成证书生成。-CA选项指明用于被签名的csr证书,-CAkey选项指明用于签名的密钥,-CAserial指明序列号文件,而-CAcreateserial指明文件不存在时自动生成。
最后生成了私用密钥:server.key和自己认证的SSL证书:server.crt
证书合并:
cat server.key server.crt > server.pem
1.8, respectively, to start the service
Start turnserver Service
/usr/local/bin/turnserver --syslog -a -f --min-port=32355 --max-port=65535 --user=dds:123456 -r dds --cert=turn_server_cert.pem --pkey=turn_server_pkey.pem --log-file=stdout -v
Start nginx Service
./usr/local/nginx/sbin/nginx
Start webrtc Service
cd / root / WebRTC / WebrtcNodeJS
node server