Home > Backend Development > PHP Tutorial > nginx reverse proxy TCP, get RTMP stream

nginx reverse proxy TCP, get RTMP stream

WBOY
Release: 2016-07-29 08:56:08
Original
2367 people have browsed it

nginx reverse proxy TCP, get RTMP stream

1. Description
nginx only supports HTTP reverse proxy by default. If you need to support TCP reverse proxy, you need to add the tcp proxy module: nginx_tcp_proxy_module.

2. 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

Three steps
1. Unzip nginx
Slightly

2. Unzip nginx_tcp_proxy_module
Unzip to /nginx-1.6.3/src/nginx_tcp_proxy_module

3.patch

<code>cd /usr/wkdir/nginx-<span>1.6</span><span>.3</span><span>patch</span> -p1 < src/nginx_tcp_proxy_module/tcp.<span>patch</span></code>
Copy after login

4. Compile & install

<code>./configure --<span>add</span>-<span>module</span>=src/nginx_tcp_proxy_module-master</code>
Copy after login

If an error is reported that a library is missing, install the corresponding library, such as openssl

<code>ubuntu下解决办法:

apt<span>-get</span> install openssl

apt<span>-get</span> install libssl<span>-dev</span>centos下解决办法:

yum <span>-y</span> install openssl openssl<span>-devel</span></code>
Copy after login

Continue to compile and install

<code><span>make</span><span>make</span> install</code>
Copy after login

5 .Modify configuration file
Add in nginx.conf, the module directive is TCP, which does not belong to the HTTP framework, so it is at the same level as HTTP{}

<code>tcp {
    upstream proxy_name {
        <span># simple round-robin</span><span>server</span> localhost:<span>1935</span>;<span>#需要代理的端口</span><span>#check interval=3000 rise=2 fall=5timeout=1000;</span><span>#check interval=3000 rise=2 fall=5timeout=1000</span><span>#check interval=3000 rise=2 fall=5timeout=1000</span><span>#check_http_send "GET /HTTP/1.0\r\n\r\n";</span><span>#check_http_expect_alive http_2xxhttp_3xx;</span>
    }

    <span>server</span> {
        listen <span>8888</span>; <span>#代理8888端口</span>        proxy_pass proxy_name;
    }
}</code>
Copy after login

6. Test
Start nginx

<code>./usr/<span>local</span>/nginx/sbin/nginx</code>
Copy after login

Start srs

<code><span>.</span>/usr/<span>local</span>/srs/objs/srs <span>-c</span> conf/srs<span>.</span>conf</code>
Copy after login

Use ffmpeg to push the rtmp stream to the srs server (port 1935), and then use vlc or other methods to get the rtmp stream to the proxy port 8888.

Self-test successful!

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces nginx reverse proxy TCP and gets RTMP stream, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template