简体   繁体   English

Nginx中用于HTML5视频标签的基于HTTPS的HLS

[英]HLS over HTTPS in nginx for HTML5 video tag

So I've been trying to get HLS working over HTTPS. 因此,我一直在尝试让HLS通过HTTPS工作。 This would seem like a simple task but I've hit a roadblock. 这似乎是一个简单的任务,但我遇到了障碍。

I can get HLS streaming over HTTP with no issues as its really straight forward. 我可以通过HTTP毫无问题地获取HLS流,因为它的确很简单。 However as soon as I change over to HTTPS non of my clients can seem to play it. 但是,一旦我切换到HTTPS,我的所有客户端似乎都无法播放它。 Most posts that I've researched want to talk about encrypting the HLS content, but i don't really care. 我研究过的大多数帖子都想谈谈加密HLS内容,但我并不在乎。 I just want to serve it. 我只想服务。

What I've also noticed is that the .m3u8 is getting downloaded by the client, but my guess is that the chunks aren't, which is why the stream errors. 我还注意到,客户端正在下载.m3u8,但是我的猜测是块未下载,这就是流错误的原因。 Also the chrome tools for debugging done show any errors on the video object. 同样,用于调试的镶边工具也会显示视频对象上的所有错误。

Here is my nginx configuration: 这是我的nginx配置:

#
    # HTTP server
    #
    server {
        listen 80;
        server_name localhost;

        root /var/www/html;
        index index.html index.htm;

        location /hls/ {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            add_header Cache-Control no-cache;
            try_files $uri $uri/ =404;
        }
    }

    #
    # HTTPS server
    #
    server {
        listen 443;
        server_name localhost;

        root /var/www/html;
        index index.html index.htm;

        ssl on;
        ssl_certificate /etc/nginx/ssl/lab.company.com.crt;
        ssl_certificate_key /etc/nginx/ssl/lab.company.com.key;
        ssl_session_timeout 5m;
        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
        ssl_prefer_server_ciphers on;

        location /hls/ {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            add_header Cache-Control no-cache;
            try_files $uri $uri/ =404;
        }
    }

This was a configuration issue. 这是一个配置问题。 You need to make sure you are not gzipping , and that the security certificate is valid . 您需要确保未gzipping ,并且安全证书有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM