Nginx reverse proxy TCP, fetch RTMP stream
I. Description
Nginx is only supported by default HTTP reverse proxy, if need to support TCP reverse proxy to add TCP Proxy module: Nginx_tcp_proxy_module.
Second, raw materials
1.nginx_tcp_proxy_module
Download Address:
wget Https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
2.nginx Source Code
Http://nginx.org/download/nginx-1.6.3.tar.gz
Third, step
1. Unzip the Nginx
Slightly
2. Unzip the Nginx_tcp_proxy_module
Unzip to/nginx-1.6.3/src/nginx_tcp_proxy_module
3.patch
cd /usr/wkdir/nginx-1.6.3patch -p1 < src/nginx_tcp_proxy_module/tcp.patch
4. Compile & Install
./configure --add-module=src/nginx_tcp_proxy_module-master
If the error is missing a library, install the appropriate library, such as OpenSSL
ubuntu下解决办法:apt-get install opensslapt-get install libssl-dev-y install openssl openssl-devel
Continue compiling the installation
makemake install
5. Modify the configuration file
Add in nginx.conf, the module directive is TCP, it is not within the HTTP framework, so and http{} the same level
tcp { upstream proxy_name { # simple round-robinserver localhost:1935;#需要代理的端口#check interval=3000 rise=2 fall=5timeout=1000;#check interval=3000 rise=2 fall=5timeout=1000#check interval=3000 rise=2 fall=5timeout=1000#check_http_send "GET /HTTP/1.0\r\n\r\n";#check_http_expect_alive http_2xxhttp_3xx; } server { 8888#代理8888端口 proxy_pass proxy_name; }}
6. Testing
Start Nginx
./usr/local/nginx/sbin/nginx
Start SRS
./usr/local-c conf/srs.conf
Use FFmpeg to push the rtmp stream to the SRS server (port 1935) and then get the rtmp stream through VLC or otherwise to agent Port 8888.
Self-Test success!
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the Nginx reverse proxy TCP, take the rtmp stream, including the aspects of the content, I hope that the PHP tutorial interested friends helpful.