【发布时间】:2017-05-24 11:54:40
【问题描述】:
我花了很多时间寻找答案,相信我已经尝试了所有方法。 我正在运行一个将 rtmp 流推送到 HLS 流的 nginx 服务器。
下面是我的 nginx.conf 的一部分
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
}
root /mnt/;
set $auth_request_uri "http://SERVER:8000/auth_ext.php?token=$arg_token";
auth_request /auth/;
add_header Cache-Control no-cache; # Prevent caching of HLS fragments
add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
}
location /auth/ {
internal;
proxy_pass $auth_request_uri;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
我正在尝试通过 php 页面对流进行身份验证,在该页面中我从 URL 获取参数,然后如果它与我的数据库中的令牌匹配,则响应 200 OK。
到目前为止,我成功地进行了身份验证,这意味着如果令牌匹配,我可以访问http://SERVER:8080/hls/stream.m3u8?token=TOKEN,但这就是发生的情况。
我有一个根据带宽调整流的主 m3u8 流,当我在控制台中访问 stream.m3u8 时,我看到了这个
http://SERVER:8080/hls/stream.m3u8?token=TOKEN
http://SERVER:8080/hls/stream_mid.m3u8
http://SERVER:8080/hls/stream_hd720.m3u8
http://SERVER:8080/hls/stream_src.m3u8
最后三个 m3u8 响应 404,因为参数不通过,因此我有一个永远不会加载但 URL 响应的流。 此外,在 m3u8 本身中,.ts 文件也得到 404。
如何处理这个问题,所以每当对第一个 m3u8 的第一次调用被验证时,剩余的 m3u8 和 ts 文件可以被访问或返回 200 代码?
我真的希望我说清楚了,我可以提供更多细节
谢谢大家
【问题讨论】:
标签: php nginx http-live-streaming m3u8