Skip to content

Commit 0c64af8

Browse files
address review comments
1 parent ca59daf commit 0c64af8

File tree

3 files changed

+216
-33
lines changed

3 files changed

+216
-33
lines changed

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

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ ms.subservice: calling
1111
ms.custom: mode-other
1212
---
1313

14-
## Force calling traffic to be proxied across your own server for Android SDK
15-
16-
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 be routed through. 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 Android SDK calling traffic be proxied to servers that you control.
17-
1814
[!INCLUDE [Public Preview](../../includes/public-preview-include-document.md)]
1915

2016
>[!IMPORTANT]
2117
> The proxy feature will NOT be available for Teams Identities and Azure Communication Services Teams interop actions.
2218
23-
### Proxy calling media traffic
19+
## Proxy calling media traffic
2420

25-
#### What is a TURN server?
21+
### What is a TURN server?
2622
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 running in a NAT (Network Address Translation) 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 Azure Communication Services mitigates network challenges by utilizing STUN and TURN](../../concepts/network-traversal.md).
2723

28-
#### Provide your TURN server details with the SDK
24+
### Provide your TURN server details with the SDK
2925
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 set up a call, see [Azure Communication Services Android SDK](../../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-android) for the Quickstart on how to setup Voice and Video.
3026

3127
```java
@@ -58,12 +54,12 @@ CallClient callClient = new CallClient(callClientOptions);
5854
> [!NOTE]
5955
> If any of the URLs provided are invalid, the `CallClient` initialization will fail and will throw errors accordingly.
6056
61-
#### Set up a TURN server in Azure
57+
### Set up a TURN server in Azure
6258
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). Coturn is a free and open source implementation of a TURN and STUN server for VoIP and WebRTC.
6359

6460
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/).
6561

66-
### Proxy signaling traffic
62+
## Proxy signaling traffic
6763

6864
To provide the URL of a proxy server, you need to pass it in as part of `CallClientOptions` through its property `Network` while initializing the `CallClient`. For more information on how to set up a call, see [Azure Communication Services Android SDK](../../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-android) for the Quickstart on how to setup Voice and Video.
6965

@@ -77,5 +73,70 @@ CallClient callClient = new CallClient(callClientOptions);
7773
// ...continue normally with your SDK setup and usage.
7874
```
7975

80-
#### Setting up a signaling proxy server on Azure
81-
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).
76+
### Setting up a signaling proxy server on Azure
77+
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).
78+
79+
Here's an NGINX config that you could make use of for a quick spin up:
80+
```
81+
events {
82+
multi_accept on;
83+
worker_connections 65535;
84+
}
85+
http {
86+
map $http_upgrade $connection_upgrade {
87+
default upgrade;
88+
'' close;
89+
}
90+
map $request_method $access_control_header {
91+
OPTIONS '*';
92+
}
93+
server {
94+
listen <port_you_want_listen_on> ssl;
95+
ssl_certificate <path_to_your_ssl_cert>;
96+
ssl_certificate_key <path_to_your_ssl_key>;
97+
location ~* ^/(.*?\.(com|net)(?::[\d]+)?)/(.*)$ {
98+
if ($request_method = 'OPTIONS') {
99+
add_header Access-Control-Allow-Origin '*' always;
100+
add_header Access-Control-Allow-Credentials 'true' always;
101+
add_header Access-Control-Allow-Headers '*' always;
102+
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
103+
add_header Access-Control-Max-Age 1728000;
104+
add_header Content-Type 'text/plain';
105+
add_header Content-Length 0;
106+
return 204;
107+
}
108+
resolver 1.1.1.1;
109+
set $ups_host $1;
110+
set $r_uri $3;
111+
rewrite ^/.*$ /$r_uri break;
112+
proxy_set_header Host $ups_host;
113+
proxy_ssl_server_name on;
114+
proxy_ssl_protocols TLSv1.2;
115+
proxy_ssl_ciphers DEFAULT;
116+
proxy_set_header X-Real-IP $remote_addr;
117+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
118+
proxy_pass_header Authorization;
119+
proxy_pass_request_headers on;
120+
proxy_http_version 1.1;
121+
proxy_set_header Upgrade $http_upgrade;
122+
proxy_set_header Connection $connection_upgrade;
123+
proxy_set_header Proxy "";
124+
proxy_set_header Access-Control-Allow-Origin $access_control_header;
125+
proxy_pass https://$ups_host;
126+
proxy_redirect https://$ups_host https://$host/$ups_host;
127+
proxy_intercept_errors on;
128+
error_page 301 302 307 = @process_redirect;
129+
error_page 400 405 = @process_error_response;
130+
}
131+
location @process_redirect {
132+
set $saved_redirect_location '$upstream_http_location';
133+
resolver 1.1.1.1;
134+
proxy_pass $saved_redirect_location;
135+
add_header X-DBUG-MSG "301" always;
136+
}
137+
location @process_error_response {
138+
add_header Access-Control-Allow-Origin * always;
139+
}
140+
}
141+
}
142+
```

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

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ ms.subservice: calling
1111
ms.custom: mode-other
1212
---
1313

14-
## Force calling traffic to be proxied across your own server for iOS SDK
15-
16-
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 be routed through. 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 iOS SDK calling traffic be proxied to servers that you control.
17-
1814
[!INCLUDE [Public Preview](../../includes/public-preview-include-document.md)]
1915

2016
>[!IMPORTANT]
2117
> The proxy feature will NOT be available for Teams Identities and Azure Communication Services Teams interop actions.
2218
23-
### Proxy calling media traffic
19+
## Proxy calling media traffic
2420

25-
#### What is a TURN server?
21+
### What is a TURN server?
2622
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 running in a NAT (Network Address Translation) 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 Azure Communication Services mitigates network challenges by utilizing STUN and TURN](../../concepts/network-traversal.md).
2723

28-
#### Provide your TURN server details with the SDK
24+
### Provide your TURN server details with the SDK
2925
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 set up a call, see [Azure Communication Services iOS SDK](../../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-ios) for the Quickstart on how to setup Voice and Video.
3026

3127
```swift
@@ -58,12 +54,12 @@ self.callClient = CallClient(options: callClientOptions);
5854
> [!NOTE]
5955
> If any of the URLs provided are invalid, the `CallClient` initialization will fail and will throw errors accordingly.
6056
61-
#### Set up a TURN server in Azure
57+
### Set up a TURN server in Azure
6258
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). Coturn is a free and open source implementation of a TURN and STUN server for VoIP and WebRTC.
6359

6460
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/).
6561

66-
### Proxy signaling traffic
62+
## Proxy signaling traffic
6763

6864
To provide the URL of a proxy server, you need to pass it in as part of `CallClientOptions` through its property `Network` while initializing the `CallClient`. For more information on how to set up a call, see [Azure Communication Services iOS SDK](../../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-ios) for the Quickstart on how to setup Voice and Video.
6965

@@ -77,5 +73,70 @@ self.callClient = CallClient(options: callClientOptions)
7773
// ...continue normally with your SDK setup and usage.
7874
```
7975

80-
#### Setting up a signaling proxy server on Azure
81-
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).
76+
### Setting up a signaling proxy server on Azure
77+
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).
78+
79+
Here's an NGINX config that you could make use of for a quick spin up:
80+
```
81+
events {
82+
multi_accept on;
83+
worker_connections 65535;
84+
}
85+
http {
86+
map $http_upgrade $connection_upgrade {
87+
default upgrade;
88+
'' close;
89+
}
90+
map $request_method $access_control_header {
91+
OPTIONS '*';
92+
}
93+
server {
94+
listen <port_you_want_listen_on> ssl;
95+
ssl_certificate <path_to_your_ssl_cert>;
96+
ssl_certificate_key <path_to_your_ssl_key>;
97+
location ~* ^/(.*?\.(com|net)(?::[\d]+)?)/(.*)$ {
98+
if ($request_method = 'OPTIONS') {
99+
add_header Access-Control-Allow-Origin '*' always;
100+
add_header Access-Control-Allow-Credentials 'true' always;
101+
add_header Access-Control-Allow-Headers '*' always;
102+
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
103+
add_header Access-Control-Max-Age 1728000;
104+
add_header Content-Type 'text/plain';
105+
add_header Content-Length 0;
106+
return 204;
107+
}
108+
resolver 1.1.1.1;
109+
set $ups_host $1;
110+
set $r_uri $3;
111+
rewrite ^/.*$ /$r_uri break;
112+
proxy_set_header Host $ups_host;
113+
proxy_ssl_server_name on;
114+
proxy_ssl_protocols TLSv1.2;
115+
proxy_ssl_ciphers DEFAULT;
116+
proxy_set_header X-Real-IP $remote_addr;
117+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
118+
proxy_pass_header Authorization;
119+
proxy_pass_request_headers on;
120+
proxy_http_version 1.1;
121+
proxy_set_header Upgrade $http_upgrade;
122+
proxy_set_header Connection $connection_upgrade;
123+
proxy_set_header Proxy "";
124+
proxy_set_header Access-Control-Allow-Origin $access_control_header;
125+
proxy_pass https://$ups_host;
126+
proxy_redirect https://$ups_host https://$host/$ups_host;
127+
proxy_intercept_errors on;
128+
error_page 301 302 307 = @process_redirect;
129+
error_page 400 405 = @process_error_response;
130+
}
131+
location @process_redirect {
132+
set $saved_redirect_location '$upstream_http_location';
133+
resolver 1.1.1.1;
134+
proxy_pass $saved_redirect_location;
135+
add_header X-DBUG-MSG "301" always;
136+
}
137+
location @process_error_response {
138+
add_header Access-Control-Allow-Origin * always;
139+
}
140+
}
141+
}
142+
```

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

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ ms.subservice: calling
1111
ms.custom: mode-other
1212
---
1313

14-
## Force calling traffic to be proxied across your own server for Windows SDK
15-
16-
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 be routed through. 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 Windows SDK calling traffic be proxied to servers that you control.
17-
1814
[!INCLUDE [Public Preview](../../includes/public-preview-include-document.md)]
1915

2016
>[!IMPORTANT]
2117
> The proxy feature will NOT be available for Teams Identities and Azure Communication Services Teams interop actions.
2218
23-
### Proxy calling media traffic
19+
## Proxy calling media traffic
2420

25-
#### What is a TURN server?
21+
### What is a TURN server?
2622
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 running in a NAT (Network Address Translation) 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 Azure Communication Services mitigates network challenges by utilizing STUN and TURN](../../concepts/network-traversal.md).
2723

28-
#### Provide your TURN server details with the SDK
24+
### Provide your TURN server details with the SDK
2925
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 set up a call, see [Azure Communication Services Windows SDK](../../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-windows) for the Quickstart on how to setup Voice and Video.
3026

3127
```csharp
@@ -58,12 +54,12 @@ CallClient callClient = new CallClient(callClientOptions);
5854
> [!NOTE]
5955
> If any of the URLs provided are invalid, the `CallClient` initialization will fail and will throw errors accordingly.
6056
61-
#### Set up a TURN server in Azure
57+
### Set up a TURN server in Azure
6258
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). Coturn is a free and open source implementation of a TURN and STUN server for VoIP and WebRTC.
6359

6460
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/).
6561

66-
### Proxy signaling traffic
62+
## Proxy signaling traffic
6763

6864
To provide the URL of a proxy server, you need to pass it in as part of `CallClientOptions` through its property `Network` while initializing the `CallClient`. For more information on how to set up a call, see [Azure Communication Services Windows SDK](../../quickstarts/voice-video-calling/get-started-with-video-calling.md?pivots=platform-windows) for the Quickstart on how to setup Voice and Video.
6965

@@ -77,5 +73,70 @@ CallClient callClient = new CallClient(callClientOptions);
7773
// ...continue normally with your SDK setup and usage.
7874
```
7975

80-
#### Setting up a signaling proxy server on Azure
81-
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).
76+
### Setting up a signaling proxy server on Azure
77+
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).
78+
79+
Here's an NGINX config that you could make use of for a quick spin up:
80+
```
81+
events {
82+
multi_accept on;
83+
worker_connections 65535;
84+
}
85+
http {
86+
map $http_upgrade $connection_upgrade {
87+
default upgrade;
88+
'' close;
89+
}
90+
map $request_method $access_control_header {
91+
OPTIONS '*';
92+
}
93+
server {
94+
listen <port_you_want_listen_on> ssl;
95+
ssl_certificate <path_to_your_ssl_cert>;
96+
ssl_certificate_key <path_to_your_ssl_key>;
97+
location ~* ^/(.*?\.(com|net)(?::[\d]+)?)/(.*)$ {
98+
if ($request_method = 'OPTIONS') {
99+
add_header Access-Control-Allow-Origin '*' always;
100+
add_header Access-Control-Allow-Credentials 'true' always;
101+
add_header Access-Control-Allow-Headers '*' always;
102+
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
103+
add_header Access-Control-Max-Age 1728000;
104+
add_header Content-Type 'text/plain';
105+
add_header Content-Length 0;
106+
return 204;
107+
}
108+
resolver 1.1.1.1;
109+
set $ups_host $1;
110+
set $r_uri $3;
111+
rewrite ^/.*$ /$r_uri break;
112+
proxy_set_header Host $ups_host;
113+
proxy_ssl_server_name on;
114+
proxy_ssl_protocols TLSv1.2;
115+
proxy_ssl_ciphers DEFAULT;
116+
proxy_set_header X-Real-IP $remote_addr;
117+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
118+
proxy_pass_header Authorization;
119+
proxy_pass_request_headers on;
120+
proxy_http_version 1.1;
121+
proxy_set_header Upgrade $http_upgrade;
122+
proxy_set_header Connection $connection_upgrade;
123+
proxy_set_header Proxy "";
124+
proxy_set_header Access-Control-Allow-Origin $access_control_header;
125+
proxy_pass https://$ups_host;
126+
proxy_redirect https://$ups_host https://$host/$ups_host;
127+
proxy_intercept_errors on;
128+
error_page 301 302 307 = @process_redirect;
129+
error_page 400 405 = @process_error_response;
130+
}
131+
location @process_redirect {
132+
set $saved_redirect_location '$upstream_http_location';
133+
resolver 1.1.1.1;
134+
proxy_pass $saved_redirect_location;
135+
add_header X-DBUG-MSG "301" always;
136+
}
137+
location @process_error_response {
138+
add_header Access-Control-Allow-Origin * always;
139+
}
140+
}
141+
}
142+
```

0 commit comments

Comments
 (0)