Answer the question
In order to leave comments, you need to log in
Nginx rtmp secure link?
Hello everyone, there was one problem, I could not solve it myself, help me solve the problem!
Task:
Implement rtmp address security using the nginx rtmp + secure link module
Here is the actual nginx.conf config
http {
server {
location /on_play {
# set connection secure link
secure_link $arg_st,$arg_e;
secure_link_md5 mysecretkey$arg_app/$arg_name$arg_e;
# bad hash
if ($secure_link = "") {
return 501;
}
# link expired
if ($secure_link = "0") {
return 502;
}
return 200;
}
}
}
rtmp {
server {
listen 1935;
notify_method get;
application movies {
live on;
on_play http://mp4.sitename.com/on_play;
}
}
}
user www-data;
#выставите worker_processes равное: cat /proc/cpuinfo | grep "processor" | sort -u | wc -l
worker_processes 24;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
$mysecretkey = "mysecretkey";
$path = "movies";
$filename = "sample.mp4";
$expiry = strtotime("+1 hour");
$b64 = base64_encode(md5($mysecretkey.$path.$expiry,true));
$b64u = rtrim(str_replace(array('+','/'),array('-','_'),$b64),'=');
$url = "rtmp://mp4.sitename.com/$path/".$filename."?e=$expiry&st=$b64u";
Результат скрипта:
rtmp://mp4.sitename.com/movies/sample.mp4?e=1455018026&st=3_JifIdDmk8Z4CYu_S3vmQ
и ошибка:
rtmp://mp4.sitename.com/movies/sample.mp4?e=1455018026: Unknown error occurred
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question