0

I am trying to get stats for nginx as rtmp server, below is my config file, but I'm getting 403 on http://ip:8080/stat.xsl (also tried http://ip/stat.xsl which gives 404 and http://ip:8080/stat/stat.xsl which gives a blank page, no error).

I've copied these settings from here: https://github.com/arut/nginx-rtmp-module

Not sure what is wrong...

I need to find a way to pull stats from the rtmp server or a way of at least getting active connections.

Thanks.

rtmp {
        server {
        listen 1935;
        chunk_size 4000;
        allow play all;

        application live {
                allow play all;
                live on;
                hls on;
                hls_nested on;
                hls_path /HLS/hls;
                hls_fragment 10s;
                record off;
                }
        }
}


http {
        include       mime.types;
        default_type  application/octet-stream;

        server {
                listen 8080;
                location /hls {
                                types {
                                        application/vnd.apple.mpegurl m3u8;
                                }
                alias /HLS/hls;
                add_header Cache-Control no-cache;
                }
                location /stat {
                        rtmp_stat all;
                        rtmp_stat_stylesheet stat.xsl;
                }
                location /stat.xsl {
                root /root/nginx-rtmp-module-dev/stat.xsl/;
                }
        }
}

UPDATE : When I access http://IP:8080/stat/stat.xsl I'm seeing this in Chrome console which I think is related : Resource interpreted as Stylesheet but transferred with MIME type text/xml: http://IP:8080/stat/stat.xsl

omega1
  • 416
  • 3
  • 9
  • 29

4 Answers4

3

I had a similar problem with the RTMP stats.

First, the root location for stat.xsl must be the directory holding stat.xsl. The root location must not be a direct path to stat.xsl. In my case, I placed it in: /var/www/stat.xsl. See location /stat.xsl below:

Secondly, I added 'allow all' to allow anyone to view the stats page. I also added in a refresh header that will cause the stats to update every third second.

This is the contents of my /etc/nginx/sites_available/default file:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    server_name localhost;

    location / {
            try_files $uri $uri/ =404;
            index index.html index.htm index.nginx-debian.html;
    }

    location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
        # Allow access from any visitor
        allow all;
        # Live updates for the stat page
        add_header Refresh "3; $request_uri";
    }

    location /stat.xsl {
        root /var/www/;
    }
}

Then, when you visit http://<hostname>/stat you'll see the RTMP stats presented for each configured stream.

thran
  • 31
  • 4
1

Check the permissions on /root/nginx-rtmp-module-dev/stat.xsl/stat.xsl and its parent directories, then. You will find that /root is not readable by the web server, thus you get a 403 error.

To fix the problem, move the file to an appropriate location, and change the nginx configuration to match.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • Hi Michael, thank you, I have moved the file to /usr/local/nginx/html/stat.xsl and permissions are readable. I am seeing this in Chrome console stat.xsl:2 Resource interpreted as Stylesheet but transferred with MIME type text/xml: "http://IP:8080/stat/stat.xsl" – omega1 Oct 30 '18 at 16:04
0

I think issue must be resolved already. But i have struggled with the same issue and found the solution that, we need to access the statistics using routing url, not with the file name. For example: example.com/stat then stat will redirect to the actual page. There we can see the table with RTMP Statistics.

Venu Kommu
  • 16
  • 2
0

copy the nginx-rtmp-stat.xsl to your nginx-rtmp html folder.

set stat.xsl path to nginx-rtmp html folder

location /stat.xsl {
                root /path-to-nginx-rtmp-html-folder/;
}

and go to http://yourip/stat