Mastering Nginx

(Ron) #1

The NGINX HTTP Server


[ 138 ]

Directive Explanation
mp4_buffer_
size

Sets the initial buffer size for delivering
MP4 files.
mp4_max_
buffer_size

Sets the maximum size of the buffer used
to process MP4 metadata.

Activating FLV pseudo-streaming for a location is as simple as just including the


flv keyword:


location /videos {

flv;

}

There are more options for MP4 pseudo-streaming, as the H.264 format includes


metadata that needs to be parsed. Seeking is available once the "moov atom" has


been parsed by the player. So to optimize performance, ensure that the metadata
is at the beginning of the file. If an error message such as the following shows up


in the logs, the mp4_max_buffer_size needs to be increased:


mp4 moov atom is too large


mp4_max_buffer_size can be increased as follows:


location /videos {

mp4;

mp4_buffer_size 1m;

mp4_max_buffer_size 20m;

}

Predefined variables


NGINX makes constructing configurations based on the values of variables easy.
Not only can you instantiate your own variables by using the set or map directives,


but there are also predefined variables used within NGINX. They are optimized for


quick evaluation and the values are cached for the lifetime of a request. You can use
any of them as a key in an if statement, or pass them on to a proxy. A number of


them may prove useful if you define your own log file format. If you try to redefine
any of them, though, you will get an error message as follows:

Free download pdf