arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.23k stars 3.49k forks source link

Can the RTMP block be used inside the sites-enabled directory? #1492

Open firewire10000 opened 4 years ago

firewire10000 commented 4 years ago

My RTMP block works perfectly inside the /etc/nginx/nginx.conf but as soon as I add it into a file under /etc/nginx/sites-enabled directory I get error messages. My simple question can RTMP blocks be read from the sites-enabled directory? If so how do I get it to work please?

Lax commented 4 years ago

rtmp block must be put in root context. If you put the configuration inside sites-enabled, it is included in http {} context, which will not work.

see https://github.com/arut/nginx-rtmp-module/wiki/Directives#rtmp

firewire10000 commented 4 years ago

rtmp block must be put in root context. If you put the configuration inside sites-enabled, it is included in http {} context, which will not work.

see https://github.com/arut/nginx-rtmp-module/wiki/Directives#rtmp

Can the sites-enabled be excluded from the HTTP block and still be picked by the nginx.conf still, or will it not work that way?

Inside the /etc/nginx/nginx.conf could I place the following?

rtmp {
    include /etc/nginx/sites-enabled/*
}
Lax commented 4 years ago

Please do not do this kind of mixing files, they are different kind, it will make things complicated and error prone.

http {
  include sites-enabled/*.conf;
}

rtmp {
  include rtmp-enabled/*.conf;
}

anyway, if you still want to put them in same folder, you can use different file name pattern(for example different file name extension).

http {
  include sites-enabled/*.conf;
}

rtmp {
  include sites-enabled/*.rtmp;
}
firewire10000 commented 4 years ago

Sadly appending an extension to the file that holds my RTMP block and then modifying the nginx.conf file still doesn't work.

nginx: [emerg] "rtmp" directive is not allowed here in /etc/nginx/sites-enabled/livestream.rtmp:3

pyk commented 4 years ago

@firewire10000 You are redefining rtmp directive inside rtmp, that's why the error happen.

If your /etc/nginx/sites-enabled/*.rtmp files contains the following:

rtmp {
    server {
        listen 1935;
        application live {
            live on;
        }
    }
}

You should remove the rtmp directive:

    server {
        listen 1935;
        application live {
            live on;
        }
    }