arut / nginx-rtmp-module

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

Add support for https-urls in notify methods. #698

Open aleksanb opened 8 years ago

aleksanb commented 8 years ago

We have a use-case where we have to authenticate rtmp-sessions against an API which is only available on https.

It seems that one currently cannot use https-urls in methods like on_publish, so we've worked around the problem by using nginx as an http->https proxy like this:

on_publish http://localhost/api-https-proxy/....;
location /api-https-proxy {
     # Strips the api-https-proxy part of
     # the url, but forward the rest.
     rewrite  ^/api-https-proxy/(.*) /$1 break;
     proxy_pass https://my-web.page;
}

Is there any way to have this functionality integrated in nginx-rtmp?

luukverhoeven commented 8 years ago

@aleksanb Interesting way to use the on_publish for authentication. How do you block a connection or publisher? with this API?

aleksanb commented 8 years ago

We send a 'stream-key' as an extra parameter during rtmp connect. As the nginx-notify module appends all arguments from the original connection to the on_publish, etc methods, the authentication server can then check the received stream-key from the nginx-rtmp server, and deny (return a 4xx response code) if the stream-key doesn't match the one originally provided by our authentication server.

Nginx-rtmp will then drop the connection.

luukverhoeven commented 8 years ago

Nice, didn't know that was possible that way.

misiek08 commented 8 years ago

@luukverhoeven can't belive you :) You better read the Directives wiki page, because this module has a lot features like that and you can do very great things with http requests (notify and control sub-modules).

@aleksanb I think you should stay at your approach, because it's just bullet-proof and "production ready".

marcoeg commented 7 years ago

+1 for https in directives callbacks

marcoeg commented 7 years ago

Reading what @aleksanb is doing, I think it is an excellent approach in any case.

namgk commented 6 years ago

needing this as well, any progress??