kaltura / nginx-srt-module

Nginx SRT/TCP gateway
GNU Affero General Public License v3.0
82 stars 15 forks source link

Nginx SRT Module

Haivision SRT (Secure Reliable Transfer) / TCP gateway. Supports both SRT to TCP and TCP to SRT, including bidirectional data transfer.

The implementation uses libsrt for SRT communication. The libsrt code executes on a side thread, eventfd notifications are used in order to communicate with the main nginx thread.

Build

Build Status

To link statically against nginx, cd to nginx source directory and execute:

./configure --add-module=/path/to/nginx-srt-module --with-stream --with-threads

To compile as a dynamic module (nginx 1.9.11+), use:

./configure --add-dynamic-module=/path/to/nginx-srt-module --with-stream --with-threads

In this case, the load_module directive should be used in nginx.conf to load the module.

Configuration

Sample configuration

# SRT -> TCP proxy
srt {
    server {
        listen 4321;
        proxy_pass tcp://127.0.0.1:5678;
    }
}

# TCP -> SRT proxy
stream {
    server {
        listen 5432;
        srt_proxy_pass srt://127.0.0.1:4321;
    }
}

srt core directives

srt

Provides the configuration file context in which the srt server directives are specified.

server

Sets the configuration for a server.

listen

Sets the address and port for the UDP socket on which the server will accept connections.

See the documentation of the listen directive of the nginx stream module for more details on the optional parameters supported by this directive.

variables_hash_max_size

Sets the maximum size of the variables hash table.

variables_hash_bucket_size

Sets the bucket size for the variables hash table.

error_log

Configures logging, see the documentation of the nginx core error_log directive for more details.

fc_pkts

Sets the maximum number of "in flight" packets (packets that were sent, but not yet acknowledged).

See the libsrt documentation of the SRTO_FC option for more details.

mss

Maximum segment size, in bytes.

See the libsrt documentation of the SRTO_MSS option for more details.

recv_buf

Receive buffer size, in bytes.

See the libsrt documentation of the SRTO_RCVBUF option for more details.

recv_udp_buf

UDP socket receive buffer size, in bytes.

See the libsrt documentation of the SRTO_UDP_RCVBUF option for more details.

recv_latency

The latency on the receiving side, in milliseconds.

See the libsrt documentation of the SRTO_RCVLATENCY option for more details.

send_buf

Send buffer size, in bytes.

See the libsrt documentation of the SRTO_SNDBUF option for more details.

send_udp_buf

UDP socket send buffer size, in bytes.

See the libsrt documentation of the SRTO_UDP_SNDBUF option for more details.

send_latency

The minimum receiving latency, provided by the sender.

See the libsrt documentation of the SRTO_PEERLATENCY option for more details.

passphrase

Sets a passphrase for encryption, see the libsrt documentation of the SRTO_PASSPHRASE option for more details.

The parameter value can contain variables.

in_buf_size

Sets the size of the buffer used for reading data from the client.

srt map directives

map

Creates a new variable whose value depends on values of one or more of the source variables specified in the first parameter.

See the documentation of the map directive of the nginx stream module for more details.

map_hash_max_size

Sets the maximum size of the map variables hash table.

map_hash_bucket_size

Sets the bucket size for the map variables hash table.

srt log directives

access_log

Sets the path, format, and configuration for a buffered log write.

See the documentation of the access_log directive of the nginx stream module for more details.

log_format

Defines a log format.

See the documentation of the log_format directive of the nginx stream module for more details.

open_log_file_cache

Defines a cache that stores the file descriptors of frequently used logs whose names contain variables.

See the documentation of the open_log_file_cache directive of the nginx stream module for more details.

srt proxy directives

proxy_pass

Sets the address of the proxied server.

proxy_connect_timeout

Defines a timeout for establishing a connection with a proxied server.

proxy_timeout

Sets the timeout between two successive read or write operations on client or proxied server connections. If no data is transmitted within this time, the connection is closed.

proxy_buffer_size

Sets the size of the buffer used for reading data from the proxied server.

proxy_protocol

Enables the PROXY protocol for connections to a proxied server.

proxy_header

Defines a string that is sent to the proxied server before any data received over SRT.

The parameter value can contain variables.

srt set misc directives

set_decode_base64

Performs base64 decode of the value of the second argument, and assigns the result to the variable specified in the first argument.

set_decode_base64url

Performs url-safe-base64 decode of the value of the second argument, and assigns the result to the variable specified in the first argument.

set_aes_decrypt

Performs AES-256-CBC decryption of the value of the last argument, using the supplied key/iv, and assigns the result to the variable specified in the first argument.

stream srt proxy directives

srt_proxy_pass

Sets the address of the proxied server.

srt_proxy_connect_timeout

Defines a timeout for establishing a connection with a proxied server.

srt_proxy_timeout

Sets the timeout between two successive read or write operations on client or proxied server connections. If no data is transmitted within this time, the connection is closed.

srt_proxy_buffer_size

Sets the size of the buffer used for reading data from the proxied server.

srt_proxy_stream_id

Sets the SRT stream id, see the libsrt documentation of the SRTO_STREAMID option for more details.

The parameter value can contain variables.

srt_proxy_passphrase

Sets a passphrase for encryption, see the libsrt documentation of the SRTO_PASSPHRASE option for more details.

The parameter value can contain variables.

Embedded Variables

Core

Upstream

Copyright & License

All code in this project is released under the AGPLv3 license unless a different license for a particular library is specified in the applicable library path.

Copyright © Kaltura Inc. All rights reserved.