Hello,

I had a 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 rtmp protocol.

Do you know how can I enable rtmp traffic

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
3 answers

Hi Arturo, to use Nginx with an RTMP app you will need to install and import the RTMP module for Nginx. Here are the instructions from the official docs https://docs.nginx.com/nginx/admin-guide/dynamic-modules/rtmp/

Thanks for your response, but I am using https://github.com/illuspas/Node-Media-Server and it is managing the rtmp server in nodejs.

So I think that if I install that ngnix module node-media-server wont work

I need this also as I have installed nginx and installed node-media-server in /var/www/html folder, By running node app.js it is working and also publishing to ip but I want to configure in via my domain with nginx server setup.

Any help would be appreciated.

Submit an Answer