→
Both SIP and XMPP can provide the same functionality. SIP is slightly more well known for voice and video while XMPP is traditionally regarded as an IM protocol. In fact, they can both be used for any of these purposes. To maximize connectivity options, it is recommended to run both in parallel.
These services rely on X.509 certificates both for authentication and confidentiality purposes. See 第 10.2.1.1 节 “公钥基础设施:easy-rsa” for details on how to create them. Alternatively the Real-Time Communications Quick Start Guide also has some useful explanations:
→
RTC services require DNS SRV and NAPTR records. A sample configuration that can be placed in the zone file for :
11.8.2. TURN Server
TURN is a service that helps clients behind NAT routers and firewalls to discover the most efficient way to communicate with other clients and to relay the media streams if no direct media path can be found. It is highly recommended that the TURN server is installed before any of the other RTC services are offered to end users.
TURN and the related ICE protocol are open standards. To benefit from these protocols, maximizing connectivity and minimizing user frustration, it is important to ensure that all client software supports ICE and TURN.
For the ICE algorithm to work effectively, the server must have two public IPv4 addresses.
11.8.2.1. Install the TURN server
Install the resiprocate-turn-server package.
Edit the /etc/reTurn/reTurnServer.config
configuration file. The most important thing to do is insert the IP addresses of the server.
- # your IP addresses go here:
- TurnAddress = 198.51.100.19
- TurnV6Address = 2001:DB8:1000:2000::19
- AltStunAddress = 198.51.100.20
- # your domain goes here, it must match the value used
- # using the HA1 algorithm:
- AuthenticationRealm = myrealm
- UserDatabaseFile = /etc/reTurn/users.txt
- UserDatabaseHashedPasswords = true
Restart the service.
11.8.2.2. Managing the TURN users
Use the htdigest utility to manage the TURN server user list.
#
Use the HUP signal to make the server reload the /etc/reTurn/users.txt
file after changing it or enable the automatic reload feature in /etc/reTurn/reTurnServer.config
.
A SIP proxy server manages the incoming and outgoing SIP connections between other organizations, SIP trunking providers, SIP PBXes such as Asterisk, SIP phones, SIP-based softphones and WebRTC applications.
It is strongly recommended to install and configure the SIP proxy before attempting a SIP PBX setup. The SIP proxy normalizes a lot of the traffic reaching the PBX and provides greater connectivity and resilience.
11.8.3.1. Install the SIP proxy
Edit the /etc/repro/repro.config
configuration file. The most important thing to do is insert the IP addresses of the server. The example below demonstrates how to setup both regular SIP and WebSockets/WebRTC, using TLS, IPv4 and IPv6:
Use the utility to manage the admin password for the web interface. The username must be admin and the realm name must match the value specified in repro.config
.
#
Restart the service to use the new configuration.
11.8.3.2. Managing the SIP proxy
Go to the web interface at http://sip-proxy.falcot.com:5080
to complete the configuration by adding domains, local users and static routes.
The first step is to add the local domain. The process must be restarted after adding or removing domains from the list.
The proxy knows how to route calls between local users and full SIP address, the routing configuration is only necessary for overriding default behavior, for example, to recognize phone numbers, add a prefix and route them to a SIP provider.
11.8.4. XMPP Server
An XMPP server manages connectivity between local XMPP users and XMPP users in other domains on the public Internet.
VOCABULARY XMPP or Jabber?
XMPP is sometimes referred to as Jabber. In fact, Jabber is a trademark and XMPP is the official name of the standard.
Prosody is a popular XMPP server that operates reliably on Debian servers.
11.8.4.1. Install the XMPP server
Install the prosody package. Using the package from jessie-backports is highly recommended, as it has the latest improvements for maximizing connectivity and resilience.
Review the /etc/prosody/prosody.cfg.lua
configuration file. The most important thing to do is insert JIDs of the users who are permitted to manage the server.
- admins = { "joe@falcot.com" }
An individual configuration file is also needed for each domain. Copy the sample from /etc/prosody/conf.avail/example.com.cfg.lua
and use it as a starting point. Here is :
To enable the domain, there must be a symlink from /etc/prosody/conf.d/
. Create it that way:
Restart the service to use the new configuration.
11.8.4.2. Managing the XMPP server
- # prosodyctl adduser joe@falcot.com
See the Prosody online documentation for more details about how to customize the configuration.
Some administrators prefer to run all of their RTC services on port 443. This helps users to connect from remote locations such as hotels and airports where other ports may be blocked or Internet traffic is routed through HTTP proxy servers.
To use this strategy, each service (SIP, XMPP and TURN) needs a different IP address. All the services can still be on the same host as Linux supports multiple IP addresses on a single host. The port number, 443, must be specified in the configuration files for each process and also in the DNS SRV records.
11.8.6. Adding WebRTC
Falcot wants to let customers make phone calls directly from the web site. The Falcot administrators also want to use WebRTC as part of their disaster recovery plan, so staff can use web browsers at home to log in to the company phone system and work normally in an emergency.
IN PRACTICE Try WebRTC
If you have not tried WebRTC before, there are various sites that give an online demonstration and test facilities.
→ http://www.sip5060.net/test-calls
WebRTC is a rapidly evolving technology and it is essential to use packages from the jessie-backports or Testing distributions.
JSCommunicator is a generic, unbranded WebRTC phone that does not require any server-side scripting such as PHP. It is built exclusively with HTML, CSS and JavaScript. It is the basis for many other WebRTC services and modules for more advanced web publishing frameworks.
→
The package jscommunicator-web-phone is the quickest way to install a WebRTC phone into a web site. It requires a SIP proxy with a WebSocket transport. The instructions in 第 11.8.3.1 节 “Install the SIP proxy” include the necessary details to enable the WebSocket transport in the repro SIP proxy.
安装 jscommunicator-web-phone后,有多种使用方式。简单手段是包含或者复制 /etc/jscommunicator-web-phone/apache.conf
中的配置来作为 Apache 虚拟主机配置。
Once the web-phone files are available in the web server, customize the to point at the TURN server and SIP proxy. For example:
More advanced click-to-call web sites typically use server-side scripting to generate the config.js
file dynamically. The source code demonstrates how to do this with PHP.
This chapter sampled only a fraction of the available server software; however, most of the common network services were described. Now it is time for an even more technical chapter: we’ll go into deeper detail for some concepts, describe massive deployments and virtualization.