Long time listener, first time caller.
I want to know if there is a way to keep someone from hijacking our rtmp stream without restricting the incoming source to a particular IP address (which is what we are currently doing). The reason for this is that our isp may change our source IP on us at any time unless we pay more for a static IP (and we will if there are no other workarounds to this issue). We are using:
nginx server with the rtmp streaming module
Here is the setup:
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
meta copy;
hls on;
hls_path /mnt/hls/live;
hls_fragment 5s;
hls_playlist_length 10s;
allow publish IP_ADDRESS_GOES_HERE;
deny publish all;
}
}
We are using a key with the player so that the source streamer needs to provide the key that the player will check. But this is easily viewable from the player page's source code along with the domain of the stream server which can be used to get an ip. So, if we turned off the "deny publish all" setting above anyone with the ip and the key can send a stream of their own to our website.
Again, the goal here is to be able to restrict the rtmp from receiving stream sources that aren't from our organization. I am not a security expert, IT professional, or nginx expert. I am guessing the answer(s) is going to be obvious to many of you, but if you could boil it down for an entry level person I'd much appreciate it. Thanks!
UPDATE:
I've attempted to use the on_publish directive and added the following changes:
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
on_publish http://localhost:8000/auth;
meta copy;
hls on;
hls_path /mnt/hls/live;
hls_fragment 5s;
hls_playlist_length 10s;
# allow publish IP_ADDRESS_GOES_HERE;
# deny publish all;
}
}
and
http {
...
server {
...
listen 8000;
location /auth{
if ($arg_user != 'usernamegoeshere') {
return 404;
}
if ($arg_psk = 'passwordgoeshere') {
return 201;
}
return 404;
}
...
}
...
}
Using authentication with OBS does not connect. However, if I change all of the 404s to 201s the stream passes. Any thoughts? What am I missing?