Skip to content

Directives

winshining edited this page Nov 2, 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_transfer_encoding

Syntax: chunked_transfer_encoding on|off
Default: chunked_transfer_encoding 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 chunked_transfer_encoding Nginx supports replaces the feature chunked provides.

location /live {
    flv_live on;
    chunked_transfer_encoding 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;

notify_no_resolve

Syntax: notify_no_resolve on|off
Default: notify_no_resolve on
Context: rtmp, server, application
Used to control the action taken by Nginx for notifications. The interface getaddrinfo used to resolve the domain names is blocking, it may cost so much time to get the IPs from the DNS servers and that is UNACCEPTABLE for Nginx addressing thousands connections, so unless you can resolve the domain names very quickly, it is better to set it as on and use IPs instead of domain names in on_connect, on_play and so on.

notify_no_resolve off;

Log

log_interval

Syntax: log_interval 5s
Default: log_interval 0s
Context: rtmp, server, application
Interval used by log module to log in access.log. nginx-http-flv-module logs only access information after connections is closed by default, so we can not get the information of connections especially when error_log is set as error until the connections is closed. It is a useful directive for debug. Note that 0s means that timing log is off.

log_interval 5s;

log_size

Syntax: log_size 128K
Default: log_size 1m
Context: rtmp, server, application
Buffer size used by log module to log in access.log. Note that 0 or negative value is invalid.

log_size 1m;