Skip to content

Directives

winshining edited this page Apr 6, 2018 · 31 revisions

Table of Contents

This table is only for the new added directives in this module, for details of other directives, please refer to nginx-rtmp-module directives.

HTTP Live FLV

flv_live

Syntax: flv_live on|off
Default: flv_live off
Context: location
Enable playing a live flv stream in this location.

location /live {
    flv_live on;
}

chunked (deprecated)

Syntax: chunked on|off
Default: chunked off
Context: location
Add a Transfer-Encoding: chunked HTTP header when sending response to the player and enable HTTP chunked transmission, otherwise Expires: -1 HTTP header is sent. Note that not all players support HTTP chunked transmission.

Since the latest codes have become more and more compatible with HTTP modules Nginx supplies, the standard directive Nginx supports chunked_transfer_encoding replaces the feature chunked provides.

location /live {
    flv_live on;
    chunked on;
}

Gop Cache

gop_cache

Syntax: gop_cache on|off
Default: gop_cache off
Context: application
Cache GOP(s) (Group Of Pictures) when a stream is being published, once a play is coming, send the cached GOP(s) at first. This decreases the time waiting for the first picture of a video to be displayed. Note that gop_cache will not function when a pull stream is played, since publish on the remote host is triggered after play is initialed, there is no GOP yet at that time.

application myapp {
    ...
    gop_cache on;
}

Virtual Hosts

server_name

Syntax: server_name *.domain.suffix|prefix.domain.*|prefix.domain.suffix|regexp
Default: --
Context: server
The functionality of server_name directive is as same as in the http block.

server_name prefix.domain.suffix;

Add HTTP Headers

add_header

Syntax: add_header name value [always];
Default: --
Context: http, server, location, if in location
Adds the specified field to a response header provided that the response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), or 308 (1.13.0). The value can contain variables.

There could be several add_header directives. These directives are inherited from the previous level if and only if there are no add_header directives defined on the current level.

If the always parameter is specified (1.7.5), the header field will be added regardless of the response code.

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';

Notify

on_connect

Syntax: on_connect url;
Default: --
Context: rtmp, server
Compatible with on_connect directive in nginx-rtmp-module, please refer to on_connect in nginx-rtmp-module.

on_connect http://example.com/on_connect.php;

on_play;

Syntax: on_play url;
Default: --
Context: rtmp, server, application
Compatible with on_play directive in nginx-rtmp-module, please refer to on_play in nginx-rtmp-module.

on_play http://example.com/on_play.php;
Clone this wiki locally