nginx-rtmp-module icon indicating copy to clipboard operation
nginx-rtmp-module copied to clipboard

Authentication Does not work

Open ghost opened this issue 5 years ago • 6 comments

Hello,

i have configured authentication as follows:

rtmp {
        server {
                listen 1935;
                chunk_size 8192;

                application hls {
                        on_play http://url.com/auth;
                        on_publish http://url.com/auth;
                        live on;
                        meta copy;
                        hls on;
                        hls_path /tmp/hls;
        }
    }
}

Still, I can publish streams to the server without a problem or without given arguments at all. The auth-url provides a 404 when password is wrong (as described here https://smartshitter.com/musings/2017/12/nginx-rtmp-streaming-with-simple-authentication/)

Whats going wrong here?

Thank you

ghost avatar Sep 03 '19 20:09 ghost

Try making the auth page throw a 500 error code for a failure. 200 to allow.

UKNickyD avatar Sep 07 '19 14:09 UKNickyD

Thank you for the reply :)

Still, it doesn't work like that :-( I can publish streams and it works even when explicit providing wrong pw.

RTMP-Server:

rtmp { server { listen 1935; chunk_size 8192;

            application hls {
                    on_play http://url.com/auth;
                    on_publish http://url.com/auth;
                    live on;
                    meta copy;
                    hls on;
                    hls_path /tmp/hls;
    }
}

}

server {

Auth directive:

    listen       80;
    server_name  tv.url.com;


    location /auth {
            if ($arg_psk = 'totallysecretpassword') {
                    return 200;
            }
            return 500;
    }

}

ghost avatar Sep 08 '19 13:09 ghost

I don't know if you have found the solution for this. Did you try adding "notify_method get;" below chunk size in rtmp conf?

Ashsanti avatar Oct 25 '19 09:10 Ashsanti

Are you using HTTPS/SSL on your server? NGINX will refuse to check a route if you try HTTP while HTTPS is active, even on localhost

jakecausier avatar Dec 14 '19 03:12 jakecausier

I think @Ashsanti is right. rtmp module use POST method as default http method. you need to add "notify_method get" to change it to the GET method Directives#notify_method

yasirubhagya avatar Jan 05 '20 04:01 yasirubhagya

the on_play is not called with hls, you have to use nginx http classic authentication I think but it is not working for me if someone has successfully done this in pass please help

sdkao avatar Sep 11 '22 05:09 sdkao