Geo-block Wowza CDN on Fastly stream targets with the Wowza Streaming Cloud REST API

The Wowza Streaming Cloud™ service allows you to selectively allow or block access to Wowza CDN on Fastly stream targets so that you can control where a stream can be viewed. Learn how to use the REST API to control the locations where your stream can be viewed.

Note: This article applies to Wowza CDN on Fastly stream targets only. To geo-block Wowza CDN on Akamai stream targets, see Geo-block stream targets with the Wowza Streaming Cloud REST API.

Before you start


You should complete the following tasks:

  • Create a transcoder. You'll need the resulting transcoder_id to assign the token-authenticated stream target to the transcoder. View our Connect a source topics to learn how to create a live stream or transcoder for RTMP, RTSP, IP camera, SRT encoder, UDP encoder, WebRTC, and Wowza Streaming Engine.

You should be familiar with the following concepts:

  • API authentication methods. Use HMAC authentication for production environments. For testing or proof of concept purposes only, use API key and access key authentication.
  • Environment variables. We use environment variables for the API version and your API and access keys in the cURL API request examples in this topic to make it easier for you to copy, paste, and run commands in your Terminal or Command Prompt window. If you don't set environment variables for these values, you'll need to manually enter the correct values in the code samples throughout this tutorial. See Tools for testing the API for instructions.

1. Add a Wowza CDN on Fastly stream target for HLS playback


Create a Wowza stream target configured to play streams from Wowza CDN on Fastly over HLS by sending a POST request to the /stream_targets/fastly endpoint. You can enable geo-blocking during this step, configure which locations are allowed or blocked, and configure any IP address overrides you may need.

You can use the following sample request, making sure to:

  • Set geoblock_enabled to true
  • Set geoblock_by_location to allow.
  • Set geoblock_country_codes to the locations affected by the geo-blcoking. Enter a comma-separated list of uppercase two-letter ISO 3166-1 country codes. For a list, see ISO 3166-1 on Wikipedia.
  • Set geoblock_ip_override to allow or deny. allow permits access from IP addresses within a location that's been blocked, while deny restricts access from IP addresses within locations that are allowed. 
  • Set geoblock_ip_addresses to addresses that can access or restrict the stream even if they're within a specified geo-blocked location. Use a comma-separated list of IPv4 and IPv6 IP addresses that always allow or deny streaming based on the geoblock_ip_override value.

Sample request

Endpoint Reference

curl -X POST \
-H "Content-Type: application/json" \
-H "wsc-api-key: ${WSC_API_KEY}" \
-H "wsc-access-key: ${WSC_ACCESS_KEY}" \
-d '{
   "stream_target_fastly": {
     "name": "MyHLSTarget",
     "geoblock_enabled": true,
     "geoblock_by_location": "allow",
     "geoblock_country_codes": "DE, US",
     "geoblock_ip_override": "deny",
     "geoblock_ip_addresses": "1.2.3.4, 9.8.7.6"
     "referer_enabled": false
   }
 }' "${WSC_HOST}/api/${WSC_VERSION}/stream_targets/fastly"

The response includes:

  • A stream_target_id you will use to assign stream targets.

Sample response

{
  "stream_target_fastly": {
    "id": "1234abcd",
    "name": "MyHLSTarget",
    "state": "activated",
    "stream_name": "st1r2eam",
    "delivery_protocols": [
        "hls"
    ],
    "playback_urls": {
      "hls": [
        {
	  "name": "default",
          "url": "https://[subdomain].wowza.com/1/[stream_id]/[stream_name]/hls/live/playlist.m3u8"
         }
      ]
    },
    "token_auth_enabled": false,
    "token_auth_playlist_only": false,
    "geoblock_enabled": true,
    "geoblock_by_location": "allow",
    "geoblock_country_codes": "DE, US",
    "geoblock_ip_override": "deny",
    "geoblock_ip_addresses": "1.2.3.4, 9.8.7.6",
    "force_ssl_playback": false,
    "created_at": "2016-02-23T16:04:23.170Z",
    "updated_at": "2016-02-23T16:04:23.170Z"
  }
}

2. Assign the geo-blocked stream target to a transcoder's output rendition


You can use the following sample request, making sure to:

  • Set stream_target_id to the id listed in the response from step 1. 
  • Set transcoder_id to the id for the transcoder.
  • Set output_id to the id for the output rendition.

Sample request

Endpoint Reference

curl -X POST \
-H "Content-Type: application/json" \
-H "wsc-api-key: ${WSC_API_KEY}" \
-H "wsc-access-key: ${WSC_ACCESS_KEY}" \
-d '{
   "output_stream_target": {
     "stream_target_id": "1234abcd"
   }
 }' "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]/outputs/[output_id]/output_stream_targets/"

Sample response

{
   "output_stream_target": {
    "stream_target_id": "1234abcd"
   }
}

More resources


Related requests