# Configure Web Server for WebRTC

Overview

Note: These instructions are required only if you are going to host WebRTC on separate server with the MiVoice 5000 ICP. If you are going to host the application on MBG itself, these instructions are unnecessary.

After configuring MBG to support WebRTC on a separate server, download the Software Development Kit (SDK) from the WebRTC. The SDK includes the settings you have configured on MBG (WebRTC address and port, WebRTC protocol security mode, Webserver shared secret, etc.) and allows you to deploy the application to your web server, customizing the look and operation of the pages if you desire.

Downloading the SDK and Opening the Files

To obtain the SDK:

1. On the MBG main page, click the Teleworking tab and click WebRTC.
2. Click Download SDK. The file (webrtc.zip) is downloaded in accordance with your web browser setup.

3. Move to file to a location of your choosing (if necessary), unzip it and examine the contents. The SDK is an archive (zipped file) that contains:

   - JavaScript libraries:
     - miwebphone.js is the SIP web phone used with Subscriber call mode.
     - miwebrtc.js is proprietary JavaScript required by the default web pages.
     - sip<-x.x.x>.js is the SIP stack that is used by miwebphone.js.
     - jquery.js is a well-known library required by miwebphone.js.
   - PHP templates and their static resources. The templates are dynamic pages containing credentials which may differ according to the user identity or time of use:

     - index.php is the default template for Subscriber call mode. It includes a login interface and the SIP credentials required to enable the web phone (miwebphone.js) to work properly. As with any web site, it is the main page that allows dynamic content.

     - config.php contains WebRTC settings configured on MBG, which are used to generate dynamic web pages.

     - call.php is the default template for Anonymous call mode. It includes ephemeral credentials delivered through CAPTCHA verification. You can make this file “plug and play” by adding a destination number or SIP URI to it. The number/URI must also be configured on the ICP.

Adding the Files to the Web Server

There are two ways to implement WebRTC on your web server:

Implement the Complete SDK

To employ this option, simply extract the contents of the SDK onto the web server to a location such as the root directory. The server requires PHP. You can then begin using the standalone service by opening the appropriate URL in the SDK folder location. For example, to initiate a call, you would enter the following addresses in a web browser:

- Anonymous call mode—https://<FQDN>/webrtc/call.php?to=<CalledNumber | SipUri>
- Subscriber call mode—https://<FQDN>/webrtc/index.php

Optionally, you can modify the implementation as follows:

1. Add a reference to the WebRTC in your own web site. To support anonymous call mode, make sure to include the destination number or SIP URI in the URL.
2. Updates the image and audio files. At the very least, hide the Mitel image by adding the "hh=1" parameter to the URL. If you have your own image and audio files, copy them to the appropriate directories and update the CSS accordingly.
3. Modify the PHP content to customize the look and operation of the service. This step is recommended only for experienced web developers.

Implement Only the JS Files

You can build your own web application using only the Javascript files included with the SDK. If your web pages are dynamically created by PHP, you can include the config.php file as in your PHP code. If your implementation does not support PHP, you must manage these parameters manually.

You are required to use the following JavaScript libraries:

- miwebphone.js — SIP web phone used with Subscriber call mode.
- sip<-x.x.x>.js — SIP stack that is used by miwebphone.js.
- jquery.js — well-known library required by miwebphone.js.

Correspondence table of config.php values and miwebphone.js constructor values:

config.php | miwebphone.js constructor
$websocket_secure | 'ws_secured'
$websocket_server | 'ws_server'
$websocket_port | 'ws_port'
$disable_video | 'disable_video'
$user_ipbx_server | 'pbxIpaddress'

Config.php values used by the web pages but not provided to the constructor:

- $webrtc_mode=1 — Used to enable/disable independently the PHP web pages.
- $enable_captcha=1 — Used to enable/disable the display of the CAPTCHA.
- $websocket_passphrase="MySecret" — Used to generate the ephemeral credentials of anonymous call.
- $webservice_server=https://my.mbg.mydomain.foo/webrtc/api/ — This is the root URL that is used to access web services on MBG, including to retrieve ICP credentials, execute directory searches and display user images.

Parent topic: WebRTC Implementation