illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.9k stars 1.51k forks source link

Nginx config. #12

Open homanp opened 6 years ago

homanp commented 6 years ago

Hi there!

Great lib :)

I was just thinking what kind of Nginx config I need to run this on let's say Digitalocean?

Any pointers would be helpful!

Thanks

illuspas commented 6 years ago

The only thing you need is a node.js runtime environment. Get from here : https://nodejs.org/en/download/

homanp commented 6 years ago

Hey thanks for the answer!

I tried installing node and the media server on digitalocean but I guess I need to configure the Nginx proxy to handle the rtmp:// protocal? Otherwise no traffic will be routed?

jacobgarcia commented 6 years ago

Hi there @homanp, I did not have to configure any NGINX additional settings for the streaming handling. Just the node runtime environment, as @illuspas told you before

arturorv00 commented 3 years ago

Hi there,

I am facing the same problem, I had the node media server running on a DO droplet and it was working as expected but now I want to migrate all my services to a different droplet because I have other domains running on the first droplet so the problem is the following:

I have: example.com example2.com example3.com

when I run node media server all domains can access the rmtp and I want only example.com to access it.

My idea was to use a reverse proxy for all my services this way:

server {
    server_name rtmp.example.com www.rtmp.example.com;

    location / {
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      # try_files $uri $uri/ =404;
        proxy_pass http://localhost:3003/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    }

}

server {
    server_name api.example.com www.api.example.com;

    location / {
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      # try_files $uri $uri/ =404;
        proxy_pass http://localhost:3001/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    }
}

But it is not working and I think nginx is blocking the rmtp protocol