简体   繁体   中英

how to use NGINX for proxy RTMP

Im using NGINX for http proxy like below

http {
server {
    server_name  example.com;

    location / {
        proxy_pass http://localhost:3000/;
    }
}
}

I would like to know anyway to use NGINX for RTMP something like

rtmp {
    server {
        server_name  example.com;
        location / {
            proxy_pass rtmp://localhost:1935;
        }
    }
}

I have looked at Nginx documentation, below configuration can be useful. Nginx TCP and UDP Load Balancing

stream {
    server {
        listen            3000;
        proxy_pass        localhost:1935;
        proxy_buffer_size 32k;
    }
}

@ismaildurmaz's answer was just about what I needed, but in my case I also wanted RTMPS (ie: RTMP over TLS). This was accomplished with:

stream {
  server {
    listen            1935 ssl;
    proxy_pass        127.0.0.1:1936;
    proxy_buffer_size 32k; 

    ssl_certificate     /path/to/ssl.crt;
    ssl_certificate_key /path/to/ssl.key;
  }
}

Here, the upstream RTMP server is configured to listen on port 1936 , since nginx listens to port 1935 on all interfaces.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM