Restrict TURN Traffic to a Region
Metered TURN Server offers a global endpoint, "global.relay.metered.ca", which automatically routes users to the nearest TURN Server based on their location.
However, for reasons such as data security and compliance, you may want to restrict TURN traffic to a specific region and use the TURN Server located in that region. For this purpose, we also provide region-specific endpoints.
To view our full list of region-specific endpoints, refer to our TURN Server Regions page.
From the dashboard, you can set the default region for your account. When you create a TURN credential and click on the "Show ICE Servers Array" button, it will display the ICE Servers array for your selected region.
For example, if you select "Global" in the dashboard and then click on the "Show ICE Servers Array" button:
It will show you the Global ICE Servers array. Notice the domain in the iceServers array is global.relay.metered.ca.
Now, if you want to restrict or pin the traffic to Canada only, so that only the TURN Servers in Canada are used to relay the traffic, select "Canada Only" from the dropdown.
If you then click on the "Show ICE Servers Array" button next to the TURN Credential, it will show you the ICE Servers array with the domain ca.relay.metered.ca.
If you use this ICE Servers array in your application, all the traffic will be relayed through the servers in Canada.
Note that if you are using the global ICE Servers array in your application and later change the region to, for example, "Canada Only" using the dropdown, your application will continue to use the global regions unless you update the ICE Servers array in your application.
Dynamically Updating Regions
If you want to automatically update the ICE Servers array in your application as you update the region using the dropdown in the dashboard, you can use the Get TURN Credential API.
This API fetches the ICE Servers array for the TURN Credential and respects the region value set in the dashboard.
So, if you have set the region value to "Global", whenever your application requests the ICE Servers array, the response will have the global endpoints. If you later update the region to something else, such as "Canada Only", the ICE Servers array returned by the API endpoint will contain the Canada Only TURN Servers.
Restricting Different TURN Credentials to Different Regions
Suppose you have a use case where you want some credentials to be restricted to the UK only, some credentials to be global, and others to be Canada only.
You can easily do this using the Get TURN Credential API.
You can set your account-level region to Global or any other region you want as the default.
If you call the Get TURN Credential API without the region parameter, it will return the ICE Servers array for the default region.
If you want to scope the credential to a particular region, simply pass the region parameter to the API, and it will return the ICE Servers array scoped to that region.
This allows you to create TURN credentials that are scoped to different regions.