Enable cross-origin resource sharing in Wowza Streaming Engine

Cross-origin resource sharing (CORS) is a mechanism that allows resources to be requested from a domain that's outside the domain from which the request originated. In general, CORS headers are required to enable browser-based HTML5 video players to fetch video and other information from Wowza Streaming Engine™ media server software instance and to allow a website in one domain to request video from a Wowza Streaming Engine server in a different domain. This article describes how to configure CORS settings in Wowza Streaming Engine.

Note: Wowza Streaming Engine 4.4.0 (or later) is required.

Configure CORS headers


This section shows how to set up CORS for streaming applications in Wowza Streaming Engine Manager. CORS headers are supported by all application types.

  1. In Wowza Streaming Engine Manager, in the Applications contents panel, select your application, and then click Edit.
  2. On the application page, select Cross-origin resource sharing (CORS), and then click Save.

Note: In Wowza Streaming Engine 4.5.0 and later, this setting is enabled by default.

Enabling this option turns on a default set of CORS headers that work for all HTTP-based streaming protocols. The CORS headers are enabled for all of the selected HTTP-based Playback Types for the application. To turn on CORS headers for specific HTTP-based streaming protocols, you can manage the Playback Types list in the application settings, or you can configure properties to enable specific HTTP-based streaming protocols to have CORS enabled. You must configure properties to change the CORS header values.

Note: In Wowza Streaming Engine 4.5.0, CORS headers are enabled by default for all HTTP-based streaming protocols. (In Wowza Streaming 4.4.x, CORS headers are enabled for MPEG-DASH streaming by default.) You can disable CORS headers for HTTP-based streams by setting the [protocol]CORSHeadersEnabled property to false.

Customize CORS headers with application properties


After you enable CORS headers, you can add the properties to your application. Each CORS property is prefixed with a [protocol], which is either the appropriate protocol name (cupertino or mpegdash) or http to denote all HTTP streaming protocols.

Path
Name
Type
Notes
/Root/Application/HTTPStreamer [protocol]CORSHeadersEnabled Boolean Enables CORS headers for the specified protocol. Default value is true (Wowza Streaming Engine 4.5.0) or false (Wowza Streaming Engine 4.4.x).
Note: If you set this property to false for http, CORS headers are still provided for cupertino or mpegdash (what is provided depends on your Wowza Streaming Engine version). You must configure the [protocol]CORSHeadersEnabled property to disable CORS headers for a specific protocol. For example, set the mpegdashCORSHeadersEnabled property to false to disable CORS headers for mpegdash.
/Root/Application/HTTPStreamer [protocol]CORSHeadersEnableAge Boolean Adds Age CORS headers to the output when set to true. Default value is false.
/Root/Application/HTTPStreamer [protocol]CORSHeadersEnableMain Boolean Adds Main CORS headers to the output when set to true. Default value is true when CORS headers are enabled.
/Root/Application/HTTPStreamer [protocol]CORSHeadersSetAge String Sets a specific CORS headers to the Age list as a pipe-separated list of header name:value pairs. This allows you to override the default set for a specific header. The header name MUST start with Access-Control- (for example, Access-Control-Max-Age) to be added to the output list.
/Root/Application/HTTPStreamer [protocol]CORSHeadersAddAge String Adds specific CORS headers to the Age list as a pipe-separated list of header name:value pairs. The header name MUST start with Access-Control- (for example, Access-Control-Max-Age) to be added to the output list.
/Root/Application/HTTPStreamer [protocol]CORSHeadersRemoveAge String Removes specific CORS headers from the Age list. Specify the CORS headers to remove as a comma-separated list of CORS header names.
/Root/Application/HTTPStreamer [protocol]CORSHeadersSetMain String Sets a specific CORS headers to the Main list as a pipe-separated list of header name:value pairs. This allows you to override the default set for a specific header. The header name must start with Access-Control- (for example, Access-Control-Allow-Credentials) to be set in the output list.
/Root/Application/HTTPStreamer [protocol]CORSHeadersAddMain String Adds specific CORS headers to the Main list as a pipe-separated list of header name:value pairs. The header name must start with Access-Control- (for example, Access-Control-Allow-Credentials) to be added to the output list.
Root/Application/HTTPStreamer [protocol]CORSHeadersRemoveMain String Removes specific CORS headers from the Main list. Specify the CORS headers to remove as a comma-separated list of CORS header names.
Root/Application/HTTPStreamer [protocol]CORSDynamicEnabled Boolean (Wowza Streaming Engine 4.7.5 and later) Reflects the Origin: header value back to the client in the Access-Control-Allow-Origin header when set to true. The default value is false. Currently, there is no checking in place to validate the domain.
Root/Application/HTTPStreamer [protocol]CORSUseHostname Boolean (Wowza Streaming Engine 4.7.5 and later) Uses the fully qualified hostname in the Access-Control-Allow-Origin header when set to true. This enables badly configured clients to receive CORS responses even when they don't send a request. The default value is false.

To add any of the above CORS headers properties to a streaming application, do the following:

  1. In Wowza Streaming Engine Manager, click the Applications tab and then select the name of your application in the contents panel.
     
  2. On the application page Properties tab, click Custom in the Quick Links bar.
     
    Note: Access to the Properties tab is limited to administrators with advanced permissions. For more information, see Manage credentials.
  3. In the Custom area, click Edit.
     
  4. Click Add Custom Property, specify the property Path, Name, Type, and Value in the Add Custom Property dialog box, and then click Add:
     
  5. Click Save, and then restart the application.

Default CORS headers


CORS headers (Main)

  • Access-Control-Allow-Origin: *
  • Access-Control-Allow-Credentials: true
  • Access-Control-Expose-Headers: Date, Server, Content-Type, Content-Length
  • Access-Control-Allow-Methods: OPTIONS, GET, POST, HEAD
  • Access-Control-Allow-Headers: Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range

CORS headers (Age)

  • Access-Control-Max-Age: 60

Customize CORS headers with VHost properties


The default setting is to enable CORS headers for VHost requests that aren't serviced by an HTTP provider or application. You can adjust the default setting by adding the properties shown in the table above to your [install-dir]/VHost.xml file (You must add the properties to the last <Properties> section in VHost.xml using a text editor. Each CORS property is prefixed with a [protocol]. The following example shows a common 'options' request directed at a VHost:

<Property>
    <Name>optionsCORSHeadersAddMain</Name>
    <Value>Access-Control-Allow-Headers:X-Authorization</Value>
    <Type>String</Type>
</Property>

Configure CORS headers for HTTP providers


Wowza Streaming Engine has built-in HTTP providers and supports custom HTTP providers that provide additional information to clients. (For more details, see HTTP providers.) By default, the built-in HTTP providers include CORS headers when providing information. You can disable this functionality on a per-provider basis by adding a specific property to the HTTP provider configuration, as shown below:

<HTTPProvider>
    <BaseClass>com.wowza.wms.http.HTTPServerInfoXML</BaseClass>
    <RequestFilters>serverinfo*</RequestFilters>
    <AuthenticationMethod>admin-digest</AuthenticationMethod>
    <Properties>
        <Property>
            <Name>httpCORSHeadersEnabled</Name>
            <Value>false</Value>
            <Type>Boolean</Type>
        </Property>
    </Properties>
</HTTPProvider>