sergey-dryabzhinsky / nginx-rtmp-module

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

Need example: How to require a stream key for broadcasting to the rtmp server. #218

Open lwilletts opened 7 years ago

lwilletts commented 7 years ago

Been searching around for how protect my stream with a stream key or something similar and I can't find any examples on how to do so and even looking through the documentation has yielded any answers.

Here is what is in my nginx.conf so far:

rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;

application live {
live on;
# Turn on HLS
hls on;
hls_path /usr/local/nginx/html/hls;
hls_fragment 1;
hls_playlist_length 15;
record off;
# disable consuming the stream from nginx as rtmp
deny play all;

# repeat to twitch and youtube
push url;
push url;
}
}
}

Seems really bizarre there if there isn't a way to do this, else anyone could type in the correct URL and start streaming stuff to your server.

Fenrirthviti commented 7 years ago

This is easily accomplished with on_publish and on_play directives. For an exmaple, see:

https://github.com/Fenrirthviti/stream-site/blob/master/lib/streamauth.php

and

https://github.com/Fenrirthviti/stream-site/blob/master/src/nginx/conf.d/rtmp.conf#L16-L19

bennettwarner commented 7 years ago

@wildefyr, Fenrirthviti is exactly right. This would be done with on_publish. @benwilber has a good writeup on his blog of how this can be achieved via django, however the same can easily be done in php or any other language you may be comfortable with: https://benwilber.github.io/streamboat.tv/nginx/rtmp/streaming/2016/10/22/implementing-stream-keys-with-nginx-rtmp-and-django.html

lwilletts commented 7 years ago

Thanks all for the links. I was hoping for a simpler solution using just nginx itself rather than installing a web framework or language (don't have the greatest experience with them), but I am sure I will figure something out.

chriswiggins commented 7 years ago

Can you not restrict by IP address?

On 15/02/2017, at 5:46 AM, Laurence Willetts notifications@github.com<mailto:notifications@github.com> wrote:

Thanks all for the links. I was hoping for a simpler solution using just nginx itself rather than installing a web framework or language (don't have the greatest experience with them), but I am sure I will figure something out.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/sergey-dryabzhinsky/nginx-rtmp-module/issues/218#issuecomment-279763565, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACsxESqwwXUm75l_ITtOse3ImbsYfHj-ks5rcdpWgaJpZM4L-p0j.

lwilletts commented 7 years ago

@chriswiggins Probably not a maintenance free idea as I am with provider who issues dynamic IPs everytime you reconnect to the network.

misiek08 commented 7 years ago

You can compile nginx with Lua and write simple Lua code, but still you will need place to show your users correct URL. You can do everything with Lua, but probably you still have some web application I think.

18.02.2017 19:03 "Laurence Willetts" notifications@github.com napisał(a):

@chriswiggins https://github.com/chriswiggins Probably not a maintenance free idea as I am with provider who issues dynamic IPs everytime you reconnect to the network.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/issues/218#issuecomment-280863495, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbp9v8FEnKW60amauPaxO4LBIroegUIks5rdzKBgaJpZM4L-p0j .