爲WebRTC 應用部署Turn Server

部署WebRTC 或 SIP p2p 方案時常常會遇到p2p 沒法穿透的環境,web

這時就是TunServer 的用武之地了。dom

這裏咱們使用turnserver-0.7.3 url

 

下載confuse依賴庫.net

wget http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gzrest

tar zxvf confuse-2.7.tar.gzserver

cd confuse*blog

./configureip

make && make install部署

 

下載get

wget http://downloads.sourceforge.net/project/turnserver/turnserver-0.7.3.tar.bz2

tar jxvf turnserver-0.7.3.tar.bz2

cd turnserver*

./configure

make && make install

 

編輯配置文件

將extra 中的配置文件模版拷貝到/etc目錄下,假設您的ip 是 1.2.3.4

1,配置文件

cp extra/turnserver.conf.template  /etc/turnserver.conf

vi /etc/tunserver.conf

修改

 listen_address = { "1.2.3.4" }

修改 ## Daemon mode.
daemon = true # 修改成後臺服務方式

修改帶寬限制

## Allocation bandwidth limitation (in KBytes/s).
## 0 value means bandwidth quota disabled.
bandwidth_per_allocation = 1024


## Restricted user bandwidth (in KBytes/s).
## 0 value means bandwidth limitation disabled.
restricted_bandwidth = 0

2,認證用戶文件

cp extra/turnusers.txt.template /etc/turnusers.txt

vi /etc/turnusers.txt
 
添加一行或多行認證信息格式爲    用戶名:密碼:domain:authorized
例以下面的行:
700:700pass:domain.org:authorized
 
添加完成後,就能夠在webrtc 裏面使用stun 和tun server 了。
var configuration = {
  'iceServers': [{
    { 'url' : 'stun:1.2.3.4'} ,

    { 'url' : ‘turn:700@1.2.3.4',credential : '700pass'}
  }]
};

 

 

轉載路徑:http://blog.163.com/sir_876/blog/static/11705223201422810528434/

相關文章
相關標籤/搜索