如何创建 HLS 令牌身份验证

qar*_*tve 5 nginx rtmp http-live-streaming

我有带有令牌身份验证的 nginx rtmp 流媒体服务器,它运行良好,我将此代码用于 nginx.conf

application live {
   live on;
   on_play http://localhost:8080/on_play;
}
Run Code Online (Sandbox Code Playgroud)

location /on_play {
   secure_link $arg_st,$arg_e;
   secure_link_md5 mysecretkey$arg_app/$arg_name$arg_e;

   if ($secure_link = "") {
       return 501;
   }
   if ($secure_link = "0") {
       return 502;
   }

   return 200;
}
Run Code Online (Sandbox Code Playgroud)

我有第二个应用程序hls:

application hls {
   allow play all;
   live on;
   hls on;
   hls_path /tmp/hls;
}
Run Code Online (Sandbox Code Playgroud)

但是在这里“on_play”不起作用,我如何为rtmp创建hls令牌?

我有这个网址:

rtmp://{SERVER_IP}/live/channel1?***e=1453546548&st=-I2EcZJRXcarSjJaMRuNqA*** 
Run Code Online (Sandbox Code Playgroud)

它有效,但我想:

http://{SERVER_IP}/hls/channel1.m3u8?e=1453546548&st=-I2EcZJRXcarSjJaMRuNqA
Run Code Online (Sandbox Code Playgroud)

或者

http://{SERVER_IP}/hls/channel1.m3u8?token=unique_key_every_refresh
Run Code Online (Sandbox Code Playgroud)

你能帮我如何创建 HLS 安全网址吗?