You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/tutorials/proxy-calling-support-tutorial.md
+126-2Lines changed: 126 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,21 @@ author: sloanster
6
6
services: azure-communication-services
7
7
8
8
ms.author: micahvivion
9
-
ms.date: 04/18/2023
9
+
ms.date: 04/20/2023
10
10
ms.topic: quickstart
11
11
ms.service: azure-communication-services
12
12
ms.subservice: calling
13
13
ms.custom: mode-other
14
14
---
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
16
16
17
17
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.
18
18
19
19
>[!IMPORTANT]
20
20
> 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`.
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.
@@ -81,3 +82,126 @@ The API reference for the `CallClientOptions` object, and the `networkConfigurat
81
82
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.
82
83
83
84
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.
// While you are creating an instance of the CallClient (the entry point of the SDK):
94
+
constcallClient=newCallClient({
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 proxy middleware in express js
111
+
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.
112
+
The `createProxyMiddleware` function from that package should cover your what you need for a simple re-direct proxy setup. Here's an example usage of it with some option settings that the SDK will need to have all of our URLs working expected:
113
+
114
+
```js
115
+
constproxyRouter= (req) => {
116
+
// Your router function if you don't intend to setup a direct target
117
+
118
+
// An example:
119
+
if (!req.originalUrl&&!req.url) {
120
+
return'';
121
+
}
122
+
123
+
constincomingUrl=req.originalUrl||req.url;
124
+
if (incomingUrl.includes('/proxy')) {
125
+
return'https://microsoft.com/forwarder/';
126
+
}
127
+
128
+
return incomingUrl;
129
+
}
130
+
131
+
constmyProxyMiddleware=createProxyMiddleware({
132
+
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)
133
+
router: proxyRouter,
134
+
changeOrigin:true,
135
+
secure:false, // If you have proper SSL setup, set this accordingly
136
+
followRedirects:true,
137
+
ignorePath:true,
138
+
ws:true,
139
+
logLevel:'debug'
140
+
});
141
+
142
+
// And finally pass in your proxy middleware to your express app depending on your URL/host setup
143
+
app.use('/proxy', myProxyMiddleware);
144
+
```
145
+
146
+
> [!Tip]
147
+
If you are having SSL issues, check out the [cors](https://www.npmjs.com/package/cors) package.
148
+
149
+
### Setting up a proxy server on Azure
150
+
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).
151
+
152
+
Here's an NGINX config that you could make use of for a quick spin up:
0 commit comments