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;
}
}
- syntax:
srt { ... }
- default:
-
- context:
main
Provides the configuration file context in which the srt server
directives are specified.
- syntax:
server { ... }
- default:
-
- context:
srt
Sets the configuration for a server.
- syntax:
listen address:port [backlog=number] [bind] [ipv6only=on|off] [reuseport];
- default:
-
- context:
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.
- syntax:
variables_hash_max_size size;
- default:
1024
- context:
srt
Sets the maximum size of the variables hash table.
- syntax:
variables_hash_bucket_size size;
- default:
64
- context:
srt
Sets the bucket size for the variables hash table.
- syntax:
error_log file [level];
- default:
logs/error.log error
- context:
srt, server
Configures logging, see the documentation of the nginx core error_log
directive for more details.
- syntax:
fc_pkts number;
- default:
25600
- context:
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.
- syntax:
mss size;
- default:
1500
- context:
srt, server
Maximum segment size, in bytes.
See the libsrt documentation of the SRTO_MSS
option for more details.
- syntax:
recv_buf size;
- default:
8192 buffers
- context:
srt, server
Receive buffer size, in bytes.
See the libsrt documentation of the SRTO_RCVBUF
option for more details.
- syntax:
recv_udp_buf size;
- default:
8192 buffers
- context:
srt, server
UDP socket receive buffer size, in bytes.
See the libsrt documentation of the SRTO_UDP_RCVBUF
option for more details.
- syntax:
recv_latency size;
- default:
120ms
- context:
srt, server
The latency on the receiving side, in milliseconds.
See the libsrt documentation of the SRTO_RCVLATENCY
option for more details.
- syntax:
send_buf size;
- default:
8192 buffers
- context:
srt, server
Send buffer size, in bytes.
See the libsrt documentation of the SRTO_SNDBUF
option for more details.
- syntax:
send_udp_buf size;
- default:
65536
- context:
srt, server
UDP socket send buffer size, in bytes.
See the libsrt documentation of the SRTO_UDP_SNDBUF
option for more details.
- syntax:
send_latency size;
- default:
120ms
- context:
srt, server
The minimum receiving latency, provided by the sender.
See the libsrt documentation of the SRTO_PEERLATENCY
option for more details.
- syntax:
passphrase expr;
- default: ``
- context:
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.
- syntax:
in_buf_size size;
- default:
64k
- context:
srt, server
Sets the size of the buffer used for reading data from the client.
- syntax:
map string $variable { ... }
- default: ``
- context:
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.
- syntax:
map_hash_max_size size;
- default:
2048
- context:
srt
Sets the maximum size of the map variables hash table.
- syntax:
map_hash_bucket_size size;
- default:
32|64|128
- context:
srt
Sets the bucket size for the map variables hash table.
- syntax:
access_log path format [buffer=size] [gzip[=level]] [flush=time] [if=condition];
- default:
off
- context:
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.
- syntax:
log_format name [escape=default|json|none] string ...;
- default: ``
- context:
srt
Defines a log format.
See the documentation of the log_format
directive of the nginx stream
module for more details.
- syntax:
open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time];
- default:
off
- context:
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.
- syntax:
proxy_pass address;
- default: ``
- context:
srt, server
Sets the address of the proxied server.
- syntax:
proxy_connect_timeout timeout;
- default:
60s
- context:
srt, server
Defines a timeout for establishing a connection with a proxied server.
- syntax:
proxy_timeout timeout;
- default:
10m
- context:
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.
- syntax:
proxy_buffer_size size;
- default:
64k
- context:
srt, server
Sets the size of the buffer used for reading data from the proxied server.
- syntax:
proxy_protocol on | off;
- default:
off
- context:
srt, server
Enables the PROXY protocol for connections to a proxied server.
- syntax:
proxy_header expr;
- default: ``
- context:
srt, server
Defines a string that is sent to the proxied server before any data received over SRT.
The parameter value can contain variables.
- syntax:
set_decode_base64 $dst src;
- default: ``
- context:
srt
Performs base64 decode of the value of the second argument, and assigns the result to the variable specified in the first argument.
- syntax:
set_decode_base64url $dst src;
- default: ``
- context:
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.
- syntax:
set_aes_decrypt $dst base64_key base64_iv src;
- default: ``
- context:
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.
- syntax:
srt_proxy_pass address;
- default: ``
- context:
stream, server
Sets the address of the proxied server.
- syntax:
srt_proxy_connect_timeout timeout;
- default:
60s
- context:
srt, server
Defines a timeout for establishing a connection with a proxied server.
- syntax:
srt_proxy_timeout timeout;
- default:
10m
- context:
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.
- syntax:
srt_proxy_buffer_size size;
- default:
64k
- context:
srt, server
Sets the size of the buffer used for reading data from the proxied server.
- syntax:
srt_proxy_stream_id expr;
- default: ``
- context:
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.
- syntax:
srt_proxy_passphrase expr;
- default: ``
- context:
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 theSRTO_PEERVERSION
option for more details.pid
- PID of the worker processprotocol
- protocol used to communicate with the client, always evaluates toSRT
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 theSRTO_STREAMID
option for more details.time_iso8601
- local time, in ISO 8601 standard formattime_local
- local time, in the Common Log Format
upstream_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 resolution
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.