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.
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.
# 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 { ... }
-
main
Provides the configuration file context in which the srt server
directives are specified.
server { ... }
-
srt
Sets the configuration for a server.
listen address:port [backlog=number] [bind] [ipv6only=on|off] [reuseport];
-
server
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 size;
1024
srt
Sets the maximum size of the variables hash table.
variables_hash_bucket_size size;
64
srt
Sets the bucket size for the variables hash table.
error_log file [level];
logs/error.log error
srt, server
Configures logging, see the documentation of the nginx core error_log
directive for more details.
fc_pkts number;
25600
srt, server
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 size;
1500
srt, server
Maximum segment size, in bytes.
See the libsrt documentation of the SRTO_MSS
option for more details.
recv_buf size;
8192 buffers
srt, server
Receive buffer size, in bytes.
See the libsrt documentation of the SRTO_RCVBUF
option for more details.
recv_udp_buf size;
8192 buffers
srt, server
UDP socket receive buffer size, in bytes.
See the libsrt documentation of the SRTO_UDP_RCVBUF
option for more details.
recv_latency size;
120ms
srt, server
The latency on the receiving side, in milliseconds.
See the libsrt documentation of the SRTO_RCVLATENCY
option for more details.
send_buf size;
8192 buffers
srt, server
Send buffer size, in bytes.
See the libsrt documentation of the SRTO_SNDBUF
option for more details.
send_udp_buf size;
65536
srt, server
UDP socket send buffer size, in bytes.
See the libsrt documentation of the SRTO_UDP_SNDBUF
option for more details.
send_latency size;
120ms
srt, server
The minimum receiving latency, provided by the sender.
See the libsrt documentation of the SRTO_PEERLATENCY
option for more details.
passphrase expr;
srt, server
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 size;
64k
srt, server
Sets the size of the buffer used for reading data from the client.
map string $variable { ... }
srt
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 size;
2048
srt
Sets the maximum size of the map variables hash table.
map_hash_bucket_size size;
32|64|128
srt
Sets the bucket size for the map variables hash table.
access_log path format [buffer=size] [gzip[=level]] [flush=time] [if=condition];
off
srt, server
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 name [escape=default|json|none] string ...;
srt
Defines a log format.
See the documentation of the log_format
directive of the nginx stream
module for more details.
open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time];
off
srt, server
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.
proxy_pass address;
srt, server
Sets the address of the proxied server.
proxy_connect_timeout timeout;
60s
srt, server
Defines a timeout for establishing a connection with a proxied server.
proxy_timeout timeout;
10m
srt, server
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 size;
64k
srt, server
Sets the size of the buffer used for reading data from the proxied server.
proxy_protocol on | off;
off
srt, server
Enables the PROXY protocol for connections to a proxied server.
proxy_header expr;
srt, server
Defines a string that is sent to the proxied server before any data received over SRT.
The parameter value can contain variables.
set_decode_base64 $dst src;
srt
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 $dst src;
srt
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 $dst base64_key base64_iv src;
srt
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.
srt_proxy_pass address;
stream, server
Sets the address of the proxied server.
srt_proxy_connect_timeout timeout;
60s
srt, server
Defines a timeout for establishing a connection with a proxied server.
srt_proxy_timeout timeout;
10m
srt, server
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 size;
64k
srt, server
Sets the size of the buffer used for reading data from the proxied server.
srt_proxy_stream_id expr;
srt, server
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 expr;
srt, server
Sets a passphrase for encryption, see the libsrt documentation of the SRTO_PASSPHRASE
option for more details.
The parameter value can contain variables.
binary_remote_addr
- client address in a binary form, the length of the value is always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addressesbytes_received
- number of bytes received from the clientbytes_sent
- number of bytes sent to the clientconnection
- connection serial numberhostname
- host namemsec
- current time, in seconds with milliseconds resolutionnginx_version
- nginx versionpeer_version
- libsrt version of the remote peer, see the libsrt documentation of the SRTO_PEERVERSION
option for more details.pid
- PID of the worker processprotocol
- protocol used to communicate with the client, always evaluates to SRT
remote_addr
- client addressremote_port
- client portserver_addr
- the address of the server which accepted the connectionserver_port
- the port of the server which accepted the connectionsession_time
- session duration, in seconds with a milliseconds resolutionstatus
- session statusstream_id
- SRT stream id, see the libsrt documentation of the SRTO_STREAMID
option for more details.time_iso8601
- local time, in ISO 8601 standard formattime_local
- local time, in the Common Log Formatupstream_addr
- the IP address and port of the upstream serverupstream_bytes_received
- number of bytes received from the upstream serverupstream_bytes_sent
- number of bytes sent to the upstream serverupstream_connect_time
- time to connect to the upstream server, in seconds with millisecond resolutionupstream_first_byte_time
- time to receive the first byte of data, in seconds with millisecond resolutionupstream_session_time
- session duration, in seconds with millisecond resolutionAll 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.