Skip to content

Commit 2807bfd

Browse files
Merge pull request #235279 from sloanster/patch-16
Update proxy-calling-support-tutorial.md
2 parents f901d20 + 5f4a673 commit 2807bfd

File tree

2 files changed

+130
-7
lines changed

2 files changed

+130
-7
lines changed

articles/communication-services/how-tos/calling-sdk/spotlight.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ ms.subservice: teams-interop
99
ms.topic: how-to
1010
ms.date: 03/01/2023
1111
ms.custom: template-how-to
12-
1312
---
1413

1514
# Spotlight states
@@ -20,7 +19,6 @@ In this article, you'll learn how to implement Microsoft Teams spotlight capabil
2019

2120
Since the video stream resolution of a participant is increased when spotlighted, it should be noted that the settings done on [Video Constraints](../../concepts/voice-video-calling/video-constraints.md) also apply to spotlight.
2221

23-
2422
## Prerequisites
2523

2624
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).

articles/communication-services/tutorials/proxy-calling-support-tutorial.md

Lines changed: 130 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@ author: sloanster
66
services: azure-communication-services
77

88
ms.author: micahvivion
9-
ms.date: 04/18/2023
9+
ms.date: 04/20/2023
1010
ms.topic: quickstart
1111
ms.service: azure-communication-services
1212
ms.subservice: calling
1313
ms.custom: mode-other
1414
---
15-
# How to force calling traffic to be proxied across your own servers
15+
# How to force calling traffic to be proxied across your own server
1616

1717
In certain situations, it might be useful to have all your client traffic proxied to a server that you can control. When the SDK is initializing, you can provide the details of your servers that you would like the traffic to route to. Once enabled all the media traffic (audio/video/screen sharing) travel through the provided TURN servers instead of the Azure Communication Services defaults. This tutorial guides on how to have WebJS SDK calling traffic be proxied to servers that you control.
1818

1919
>[!IMPORTANT]
2020
> The proxy feature is available starting in the public preview version [1.13.0-beta.4](https://www.npmjs.com/package/@azure/communication-calling/v/1.13.0-beta.4) of the Calling SDK. Please ensure that you use this or a newer SDK when trying to use this feature. This Quickstart uses the Azure Communication Services Calling SDK version greater than `1.13.0`.
2121
2222
[!INCLUDE [Public Preview](../includes/public-preview-include-document.md)]
23+
## Proxy calling media traffic
2324

2425
## What is a TURN server?
2526
Many times, establishing a network connection between two peers isn't straightforward. A direct connection might not work because of many reasons: firewalls with strict rules, peers sitting behind a private network, or computers are running in a NAT environment. To solve these network connection issues, you can use a TURN server. The term stands for Traversal Using Relays around NAT, and it's a protocol for relaying network traffic STUN and TURN servers are the relay servers here. Learn more about how ACS [mitigates](../concepts/network-traversal.md) network challenges by utilizing STUN and TURN.
2627

27-
## Provide your TURN servers details to the SDK
28-
To provide the details of your TURN servers, you need to pass details of what TURN server to use as part of `CallClientOptions` while initializing the `CallClient`. For more details how to setup a call see [Azure Communication Services Web SDK](../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-web)) for the Quickstart on how to setup Voice and Video.
28+
### Provide your TURN servers details to the SDK
29+
To provide the details of your TURN servers, you need to pass details of what TURN server to use as part of `CallClientOptions` while initializing the `CallClient`. For more information how to setup a call, see [Azure Communication Services Web SDK](../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-web)) for the Quickstart on how to setup Voice and Video.
2930

3031
```js
3132
import { CallClient } from '@azure/communication-calling';
@@ -77,7 +78,131 @@ const callClient = new CallClient({
7778
7879
The API reference for the `CallClientOptions` object, and the `networkConfiguration` property within it can be found here - [CallClientOptions](/javascript/api/azure-communication-services/@azure/communication-calling/callclientoptions?view=azure-communication-services-js&preserve-view=true).
7980

80-
## Set up a TURN server in Azure
81+
### Set up a TURN server in Azure
8182
You can create a Linux virtual machine in the Azure portal using this [guide](/azure/virtual-machines/linux/quick-create-portal?tabs=ubuntu), and deploy a TURN server using [coturn](https://github.com/coturn/coturn), a free and open source implementation of a TURN and STUN server for VoIP and WebRTC.
8283

8384
Once you have setup a TURN server, you can test it using the WebRTC Trickle ICE page - [Trickle ICE](https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/).
85+
86+
## Proxy signaling traffic
87+
88+
To provide the URL of a proxy server, you need to pass it in as part of `CallClientOptions` while initializing the `CallClient`. For more details how to setup a call see [Azure Communication Services Web SDK](../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-web)) for the Quickstart on how to setup Voice and Video.
89+
90+
```js
91+
import { CallClient } from '@azure/communication-calling';
92+
93+
// While you are creating an instance of the CallClient (the entry point of the SDK):
94+
const callClient = new CallClient({
95+
networkConfiguration: {
96+
proxy: {
97+
url: 'https://myproxyserver.com'
98+
}
99+
}
100+
});
101+
102+
// ...continue normally with your SDK setup and usage.
103+
```
104+
105+
> [!NOTE]
106+
> If the proxy URL provided is an invalid URL, the `CallClient` initialization will fail and will throw errors accordingly. The error messages thrown will help you troubleshoot if you run into issues.
107+
108+
The API reference for the `CallClientOptions` object, and the `networkConfiguration` property within it can be found here - [CallClientOptions](/javascript/api/azure-communication-services/@azure/communication-calling/callclientoptions?view=azure-communication-services-js&preserve-view=true).
109+
110+
### Setting up a signaling proxy middleware in express js
111+
112+
You can also create a proxy middleware in your express js server setup to have all the URLs redirected through it, using the [http-proxy-middleware](https://www.npmjs.com/package/http-proxy-middleware) npm package.
113+
The `createProxyMiddleware` function from that package should cover what you need for a simple redirect proxy setup. Here's an example usage of it with some option settings that the SDK needs to have all of our URLs working as expected:
114+
115+
```js
116+
const proxyRouter = (req) => {
117+
// Your router function if you don't intend to setup a direct target
118+
119+
// An example:
120+
if (!req.originalUrl && !req.url) {
121+
return '';
122+
}
123+
124+
const incomingUrl = req.originalUrl || req.url;
125+
if (incomingUrl.includes('/proxy')) {
126+
return 'https://microsoft.com/forwarder/';
127+
}
128+
129+
return incomingUrl;
130+
}
131+
132+
const myProxyMiddleware = createProxyMiddleware({
133+
target: 'https://microsoft.com', // This will be ignore if a router function is provided, but createProxyMiddleware still requires this to be passed in (see it's official docs on the npm page for the most recent changes)
134+
router: proxyRouter,
135+
changeOrigin: true,
136+
secure: false, // If you have proper SSL setup, set this accordingly
137+
followRedirects: true,
138+
ignorePath: true,
139+
ws: true,
140+
logLevel: 'debug'
141+
});
142+
143+
// And finally pass in your proxy middleware to your express app depending on your URL/host setup
144+
app.use('/proxy', myProxyMiddleware);
145+
```
146+
147+
> [!Tip]
148+
> If you are having SSL issues, check out the [cors](https://www.npmjs.com/package/cors) package.
149+
150+
### Setting up a signaling proxy server on Azure
151+
You can create a Linux virtual machine in the Azure portal and deploy an NGINX server on it using this guide - [Quickstart: Create a Linux virtual machine in the Azure portal](/azure/virtual-machines/linux/quick-create-portal?tabs=ubuntu).
152+
153+
Here's an NGINX config that you could make use of for a quick spin up:
154+
```
155+
events {
156+
multi_accept on;
157+
worker_connections 65535;
158+
}
159+
160+
http {
161+
map $http_upgrade $connection_upgrade {
162+
default upgrade;
163+
'' close;
164+
}
165+
166+
server {
167+
listen <port_you_want_listen_on> ssl;
168+
ssl_certificate <path_to_your_ssl_cert>;
169+
ssl_certificate_key <path_to_your_ssl_key>;
170+
location ~* ^/(.*\.(com)(?::[\d]+)?)/(.*)$ {
171+
resolver 8.8.8.8;
172+
set $ups_host $1;
173+
set $r_uri $3;
174+
rewrite ^/.*$ /$r_uri break;
175+
proxy_set_header Host $ups_host;
176+
proxy_ssl_server_name on;
177+
proxy_ssl_protocols TLSv1.2;
178+
proxy_ssl_ciphers DEFAULT;
179+
proxy_set_header X-Real-IP $remote_addr;
180+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
181+
proxy_pass_header Authorization;
182+
proxy_http_version 1.1;
183+
proxy_set_header Upgrade $http_upgrade;
184+
proxy_set_header Connection $connection_upgrade;
185+
proxy_set_header Proxy "";
186+
proxy_pass https://$ups_host;
187+
proxy_redirect https://$ups_host https://$host/$ups_host;
188+
proxy_intercept_errors on;
189+
error_page 301 302 307 = @process_redirect;
190+
error_page 400 405 = @process_error_response;
191+
if ($request_method = 'OPTIONS') {
192+
add_header Access-Control-Allow-Origin * always;
193+
}
194+
}
195+
location @handle_redirect {
196+
set $saved_redirect_location '$upstream_http_location';
197+
resolver 8.8.8.8;
198+
proxy_pass $saved_redirect_location;
199+
add_header X-DBUG-MSG "301" always;
200+
}
201+
location @handle_error_response {
202+
add_header Access-Control-Allow-Origin * always;
203+
}
204+
}
205+
}
206+
```
207+
208+

0 commit comments

Comments
 (0)